Browse Source

Pull request #5452: 无jira 解决冲突

Merge in DESIGN/design from ~HADES/design:feature/x to feature/x

* commit 'beaaf903f9b44e207e98faa8fd39778f66ee9d69': (87 commits)
  REPORT-57128&REPORT-57657 优化代码冗余逻辑
  REPORT-57128&REPORT-57657 修复参数面板中会显示间距线的问题&修复报表块图表块不显示间距线的问题
  REPORT-57128 【FRM布局推荐】组件复用-关于悬浮hover组件的交互设计更新
  REPORT-57520 报表块内图表超链不应该显示悬浮窗图表
  REPORT-57658   处理odbc链接的共存关系
  REPORT-57438 【回归测试】权限细粒度控制-参数面板控件,控件权限编辑栏无法正常显示
  REPORT-53615  调整下combox的展示顺序
  REPORT-57317 修改间距提示文字的大小
  REPORT-57333 还原代码
  REPORT-57181 【FRM布局推荐】组件复用-自动间距目前么有把小数处理成整数
  REPORT-57333 【FRM布局推荐】组件复用-现在还不能实现绝对画布块上重叠放置组件
  REPORT-56895 还是计算间距线相对位置的问题
  REPORT-56926&REPORT-57238 解决因为修复这两个问题引起的新问题
  REPORT-56049 组件复用-组件目录树选中控件,如果选中后不移动鼠标的话,控件没有出现工具栏
  REPORT-57238 解决自动间距计算不正确的问题
  REPORT-57326&EPORT-57324&REPORT-57330&REPORT-56895 布局推荐若干间距线的bug
  REPORT-56925 【FRM布局推荐】组件复用-手动间距输入框没有显示水印
  REPORT-55756 设计器界面移动时,工具栏保持停留原位置,没有随着移动,这个看下要不要优化下。鼠标再回到设计画布就好了
  REPORT-56532 文件选择器弹窗 && REPORT-56683 文件选择器弹窗-图片压缩功能入口迁移的初次提示问题
  REPORT-56926 【FRM布局推荐】组件复用-手动间距目前不支持输入小数(允许输入小数,但自动取整处理)
  ...
research/11.0
ju|剧浩宇 3 years ago
parent
commit
6fd1d73e28
  1. 8
      build.gradle
  2. 12
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 93
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 18
      designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java
  5. 25
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  6. 24
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java
  7. 4
      designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java
  8. 3
      designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java
  9. 451
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  10. 303
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  11. 3
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  12. 2
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  13. 12
      designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java
  14. 251
      designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java
  15. 2
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java
  16. 2
      designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java
  17. 13
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  18. 16
      designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java
  19. 6
      designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java
  20. 13
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  21. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  22. 3
      designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java
  23. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java
  24. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java
  25. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  26. 63
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java
  27. 129
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java
  28. 103
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java
  29. 12
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java
  30. 5
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java
  31. 225
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java
  32. 154
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java
  33. 1
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java
  34. 60
      designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java
  35. 453
      designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java
  36. 15
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  37. 278
      designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java
  38. 399
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  39. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  40. 14
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  41. 140
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  42. 83
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java
  43. 144
      designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java
  44. 25
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  45. 21
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java
  46. 280
      designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java
  47. 9
      designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java
  48. 44
      designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java
  49. 16
      designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java
  50. 34
      designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java
  51. 25
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  52. 3
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  53. 16
      designer-base/src/main/java/com/fr/design/web/CustomIconPane.java
  54. 30
      designer-base/src/main/java/com/fr/env/HelpLink.java
  55. 36
      designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java
  56. 56
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  57. 16
      designer-base/src/main/java/com/fr/env/handler/Handler.java
  58. 28
      designer-base/src/main/java/com/fr/env/handler/RefWrapper.java
  59. 90
      designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java
  60. 30
      designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java
  61. 22
      designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java
  62. 52
      designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java
  63. 23
      designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java
  64. 26
      designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java
  65. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties
  66. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties
  67. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties
  68. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties
  69. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties
  70. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png
  71. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png
  72. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png
  73. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png
  74. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png
  75. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png
  76. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png
  77. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png
  78. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png
  79. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png
  80. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png
  81. 21
      designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java
  82. 23
      designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java
  83. 207
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  84. 32
      designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java
  85. 1
      designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java
  86. 59
      designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java
  87. 1
      designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java
  88. 38
      designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java
  89. 15
      designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java
  90. 36
      designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java
  91. 25
      designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java
  92. 16
      designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java
  93. 2
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java
  94. 15
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java
  95. 13
      designer-chart/src/main/java/com/fr/design/chartx/impl/AbstractDataPane.java
  96. 5
      designer-chart/src/main/java/com/fr/design/chartx/impl/AbstractOtherPane.java
  97. 48
      designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java
  98. 7
      designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java
  99. 112
      designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java
  100. 51
      designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java
  101. Some files were not shown because too many files have changed in this diff Show More

8
build.gradle

@ -60,10 +60,10 @@ allprojects {
implementation 'com.fr.third:jxbrowser:6.23' implementation 'com.fr.third:jxbrowser:6.23'
implementation 'com.fr.third:jxbrowser-mac:6.23' implementation 'com.fr.third:jxbrowser-mac:6.23'
implementation 'com.fr.third:jxbrowser-win64:6.23' implementation 'com.fr.third:jxbrowser-win64:6.23'
implementation 'com.fr.third:jxbrowser-v7:7.7' implementation 'com.fr.third:jxbrowser-v7:7.15'
implementation 'com.fr.third:jxbrowser-mac-v7:7.7' implementation 'com.fr.third:jxbrowser-mac-v7:7.15'
implementation 'com.fr.third:jxbrowser-win64-v7:7.7' implementation 'com.fr.third:jxbrowser-win64-v7:7.15'
implementation 'com.fr.third:jxbrowser-swing-v7:7.7' implementation 'com.fr.third:jxbrowser-swing-v7:7.15'
implementation 'com.fr.third.server:servlet-api:3.0' implementation 'com.fr.third.server:servlet-api:3.0'
implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swexpl:2.0.1'
implementation 'org.swingexplorer:swag:1.0' implementation 'org.swingexplorer:swag:1.0'

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

@ -192,6 +192,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private static List<SwingWorker> mapWorkerList = new ArrayList<SwingWorker>(); private static List<SwingWorker> mapWorkerList = new ArrayList<SwingWorker>();
private boolean imageCompress = false;//图片压缩 private boolean imageCompress = false;//图片压缩
private boolean showImageCompressMoveTip = true;
// 开启内嵌web页面的调试窗口 // 开启内嵌web页面的调试窗口
private boolean openDebug = false; private boolean openDebug = false;
@ -1655,6 +1656,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.imageCompress = imageCompress; this.imageCompress = imageCompress;
} }
public boolean isShowImageCompressMoveTip() {
return showImageCompressMoveTip;
}
public void setShowImageCompressMoveTip(boolean showImageCompressMoveTip) {
this.showImageCompressMoveTip = showImageCompressMoveTip;
}
public boolean isOpenDebug() { public boolean isOpenDebug() {
return openDebug; return openDebug;
} }
@ -1810,6 +1820,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT)); this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT));
this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true)); this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true));
this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true)); this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true));
this.setShowImageCompressMoveTip(reader.getAttrAsBoolean("showImageCompressMoveTip", true));
this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true)); this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true));
this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false)); this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false));
// peter:读取webinfLocation // peter:读取webinfLocation
@ -2091,6 +2102,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (!this.isImageCompress()) { if (!this.isImageCompress()) {
writer.attr("imageCompress", this.isImageCompress()); writer.attr("imageCompress", this.isImageCompress());
} }
writer.attr("showImageCompressMoveTip", this.isShowImageCompressMoveTip());
if (!this.isAutoBackUp()) { if (!this.isAutoBackUp()) {
writer.attr("autoBackUp", this.isAutoBackUp()); writer.attr("autoBackUp", this.isAutoBackUp());
} }

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

@ -6,7 +6,6 @@ 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;
@ -21,14 +20,11 @@ import com.fr.design.notification.NotificationCenter;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.env.RemoteWorkspaceURL; import com.fr.env.handler.RemoteDesignExceptionHandler;
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;
import com.fr.license.exception.RegistEditionException;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe; import com.fr.process.ProcessEventPipe;
@ -46,8 +42,6 @@ import com.fr.workspace.base.WorkspaceAPI;
import com.fr.workspace.connect.WorkspaceConnectionInfo; 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.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;
@ -66,7 +60,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE; import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { public class EnvChangeEntrance {
@ -79,6 +72,8 @@ public class EnvChangeEntrance {
private static EnvChangeEntrance singleton = new EnvChangeEntrance(); private static EnvChangeEntrance singleton = new EnvChangeEntrance();
} }
private BasicDialog dialog;
private EnvChangeEntrance() { private EnvChangeEntrance() {
@ -116,13 +111,6 @@ public class EnvChangeEntrance {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid(); boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) { if (!checkValid) {
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false; return false;
} }
@ -149,34 +137,9 @@ public class EnvChangeEntrance {
template.refreshToolArea(); template.refreshToolArea();
} }
pluginErrorRemind(); pluginErrorRemind();
} catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
} catch (WorkspaceCheckException e) {
handleWorkspaceCheckException(e, strategy, connectionInfo);
return false;
} catch (Exception exception) { } catch (Exception exception) {
if (exception.getCause() instanceof WorkspaceCheckException) { // 失败的处理
handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo); RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv);
} else {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
return false; return false;
} }
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
@ -188,29 +151,6 @@ 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_Tool_Tips"),
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")));
}
}
/** /**
* 这个功能留着可能会加回来先做注释处理 * 这个功能留着可能会加回来先做注释处理
* 切换远程环境之前进行版本检测当版本不一致的时候提示 * 切换远程环境之前进行版本检测当版本不一致的时候提示
@ -440,7 +380,7 @@ public class EnvChangeEntrance {
public void chooseEnv(final String envName) { public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame()); final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame());
dialog = envListDialog;
envListPane.populateEnvManager(envName); envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@ -457,6 +397,7 @@ public class EnvChangeEntrance {
@Override @Override
public void doCancel() { public void doCancel() {
envListDialog.dispose(); envListDialog.dispose();
dialog = null;
// todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口 // todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口
} }
}); });
@ -466,7 +407,7 @@ public class EnvChangeEntrance {
/** /**
* 处理异常 * 处理异常
*/ */
public void dealEvnExceptionWhenStartDesigner() { public void dealEvnExceptionWhenStartDesigner(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); ProcessEventPipe eventPipe = FineProcessContext.getParentPipe();
if (eventPipe != null) { if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
@ -474,6 +415,7 @@ public class EnvChangeEntrance {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName()); envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
dialog = envListDialog;
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
@ -489,9 +431,13 @@ public class EnvChangeEntrance {
@Override @Override
public void doCancel() { public void doCancel() {
dialog = null;
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} }
}); });
if (e != null) {
RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo);
}
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
@ -523,6 +469,9 @@ public class EnvChangeEntrance {
return false; return false;
} }
public BasicDialog getDialog() {
return dialog;
}
/** /**
* 提示显示策略 * 提示显示策略
@ -559,14 +508,4 @@ public class EnvChangeEntrance {
interface PopTip { interface PopTip {
void show(); void show();
} }
private static class SuccessPopTip implements PopTip {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Success"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
}
}
} }

18
designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java

@ -4,6 +4,8 @@ import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.HyperlinkProvider; import com.fr.design.fun.HyperlinkProvider;
import com.fr.design.fun.TableDataDefineProvider; import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.ui.util.UIUtil;
import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType; import com.fr.plugin.observer.PluginEventType;
@ -28,7 +30,7 @@ public class PluginClassRefreshManager {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
// 重载模版之前 触发下hide // 重载模版之前 触发下hide
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); fireTabChange();
// 兼容之前版本特性 // 兼容之前版本特性
for (String tag : context) { for (String tag : context) {
if (event.getContext().contain(tag)) { if (event.getContext().contain(tag)) {
@ -53,12 +55,24 @@ public class PluginClassRefreshManager {
public void on(PluginEvent event) { public void on(PluginEvent event) {
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener);
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); fireTabChange();
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate();
} }
} }
}; };
public void fireTabChange() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
template.fireTabChange();
}
});
}
}
public static PluginClassRefreshManager getInstance() { public static PluginClassRefreshManager getInstance() {
return INSTANCE; return INSTANCE;

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

@ -16,6 +16,9 @@ import com.fr.design.gui.ibutton.UINoThemeColorButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.UIProgressBarUI; import com.fr.design.gui.iprogressbar.UIProgressBarUI;
@ -48,6 +51,8 @@ import com.fr.transaction.Worker;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.git.config.GcConfig; import com.fr.workspace.server.vcs.git.config.GcConfig;
import com.sun.javafx.tk.FileChooserType;
import javafx.stage.FileChooser;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -166,6 +171,7 @@ public class PreferencePane extends BasicPane {
private UICheckBox joinProductImproveCheckBox; private UICheckBox joinProductImproveCheckBox;
private UICheckBox autoPushUpdateCheckBox; private UICheckBox autoPushUpdateCheckBox;
private UICheckBox embedServerLazyStartupCheckBox; private UICheckBox embedServerLazyStartupCheckBox;
private UICheckBox imageCompressPanelCheckBox;
private UICheckBox vcsEnableCheckBox; private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox; private UICheckBox saveCommitCheckBox;
@ -257,6 +263,10 @@ public class PreferencePane extends BasicPane {
embedServerPanel.add(embedServerLazyStartupCheckBox); embedServerPanel.add(embedServerLazyStartupCheckBox);
advancePane.add(embedServerPanel); advancePane.add(embedServerPanel);
JPanel imageCompressPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Template_Preview_Performance"));
imageCompressPanelCheckBox = new UICheckBox(i18nText("Fine-Design_Image_Compress"));
imageCompressPanel.add(imageCompressPanelCheckBox);
advancePane.add(imageCompressPanel);
} }
private void createVcsSettingPane(JPanel generalPane) { private void createVcsSettingPane(JPanel generalPane) {
@ -497,11 +507,13 @@ public class PreferencePane extends BasicPane {
chooseDirBtn.addActionListener(new ActionListener() { chooseDirBtn.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser(); FileChooserProvider fileChooserProvider =
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); new JavaFxNativeFileChooser.Builder().
int saveValue = fileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); fileSelectionMode(FileSelectionMode.DIR).
build();
int saveValue = fileChooserProvider.showDialog(chooseDirBtn);
if (saveValue == JFileChooser.APPROVE_OPTION) { if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile(); File selectedFile = fileChooserProvider.getSelectedFile();
logExportDirectoryField.setText(selectedFile.getAbsolutePath()); logExportDirectoryField.setText(selectedFile.getAbsolutePath());
} }
} }
@ -673,7 +685,7 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setSelected(false); defaultStringToFormulaBox.setSelected(false);
} }
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
if (WorkContext.getCurrent().isCluster()){ if (WorkContext.getCurrent().isCluster()) {
vcsEnableCheckBox.setEnabled(false); vcsEnableCheckBox.setEnabled(false);
gcEnableCheckBox.setEnabled(false); gcEnableCheckBox.setEnabled(false);
} }
@ -726,6 +738,8 @@ public class PreferencePane extends BasicPane {
this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup()); this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup());
this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile()); this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile());
this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress());
} }
private int chooseCase(int sign) { private int chooseCase(int sign) {
@ -784,6 +798,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected()); designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected());
designerEnvManager.setImageCompress(this.imageCompressPanelCheckBox.isSelected());
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue()); vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue());
vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());

24
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java

@ -0,0 +1,24 @@
package com.fr.design.base.clipboard;
import java.util.List;
public class ClipboardHelper {
public static String formatExcelString(List<List<Object>> table) {
StringBuffer stringBuffer = new StringBuffer();
for (int row = 0; row < table.size(); row++) {
List<Object> rowValue = table.get(row);
for (int col = 0; col < rowValue.size(); col++) {
Object cell = rowValue.get(col);
stringBuffer.append(cell);
if (col != rowValue.size() - 1) {
stringBuffer.append("\t");
}
}
if (row != table.size() - 1) {
stringBuffer.append("\n");
}
}
return stringBuffer.toString();
}
}

4
designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java

@ -3,6 +3,7 @@ package com.fr.design.base.mode;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import static com.fr.design.base.mode.DesignerMode.AUTHORITY; import static com.fr.design.base.mode.DesignerMode.AUTHORITY;
import static com.fr.design.base.mode.DesignerMode.DUCHAMP;
public class DesignModeContext { public class DesignModeContext {
@ -42,6 +43,9 @@ public class DesignModeContext {
return mode == AUTHORITY; return mode == AUTHORITY;
} }
public static boolean isDuchampMode() {
return mode == DUCHAMP;
}
public static void doCopy(TargetComponent principal) { public static void doCopy(TargetComponent principal) {
if (isBanCopyAndCut() || principal == null) { if (isBanCopyAndCut() || principal == null) {

3
designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java

@ -4,5 +4,6 @@ public enum DesignerMode {
NORMAL, NORMAL,
BAN_COPY_AND_CUT, BAN_COPY_AND_CUT,
VCS, VCS,
AUTHORITY AUTHORITY,
DUCHAMP
} }

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

@ -1,6 +1,8 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.data.driver.DriverLoader;
import com.fr.data.driver.config.DriverLoaderConfig;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -21,6 +23,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils; 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 com.fr.third.guava.collect.HashBiMap;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
@ -45,6 +49,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -97,12 +102,167 @@ public class JDBCDefPane extends JPanel {
private Component[][] partComponents; private Component[][] partComponents;
// 请不要改动dbtype,只应该最后添加 // 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB}; private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB};
private JDBCDatabaseConnection jdbcDatabase; private JDBCDatabaseConnection jdbcDatabase;
private boolean needRefresh = true; private boolean needRefresh = true;
private UIComboBox driverManageBox;
private ActionLabel driverManageLabel;
private UIComboBox driverLoaderBox;
private HashBiMap<String, String> nameAndRepresent;
ActionListener driverListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
urlTextField.setText(dus[i].getURL());
return;
}
}
}
}
};
ActionListener dbtypeButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(driverComboBox.getSelectedItem(), (dus[i].getDriver()))) {
urlTextField.setText(dus[i].getURL());
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) {
// ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
File selectedfile = null;
if (result == JFileChooser.APPROVE_OPTION) {
selectedfile = filechooser.getSelectedFile();
if (selectedfile != null) {
String selectedName = selectedfile.getPath().substring(selectedfile.getPath().lastIndexOf('.') + 1);
if (selectedName.equalsIgnoreCase("mdb") || selectedName.equalsIgnoreCase("accdb")) {
urlTextField.setText(urlTextField.getText() + selectedfile.getPath());
}
}
}
}
break;
}
}
}
};
KeyListener portKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String port = portTextField.getText();
if (isPortValid(port)) {
updateURL();
} else {
portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()), ""));
if (!isPortValid(portTextField.getText())) {
portTextField.setText(StringUtils.EMPTY);
updateURL();
}
}
}
};
ActionListener driverManageListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selectSelfDefine = isSelfDefine();
driverManageLabel.setVisible(selectSelfDefine);
driverLoaderBox.setVisible(selectSelfDefine);
driverComboBox.setVisible(!selectSelfDefine);
// 选中自定义的话,将odbc的屏蔽,选中默认的话,重新触发一次driverComboBox的事件
if (selectSelfDefine) {
odbcTipsLink.setVisible(false);
} else {
driverComboBox.setSelectedItem(driverComboBox.getSelectedItem());
}
}
};
ActionListener dbtypeActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
urlTextField.setText(StringUtils.EMPTY);
driverComboBox.removeAllItems();
driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Default"));
if (driverLoaderBox.getItemCount() > 0) {
driverLoaderBox.setSelectedIndex(0);
}
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
driverComboBox.setSelectedItem(StringUtils.EMPTY);
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
driverComboBox.addItem(dus[i].getDriver());
if (i == 0) {
driverComboBox.setSelectedItem(dus[i].getDriver());
urlTextField.setText(dus[i].getURL());
}
}
// 更改数据库类型后 数据库名称置空和之前逻辑保持一致
if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem());
JDBCConnectionDef.getInstance().setConnection((String) dbtypeComboBox.getSelectedItem(), jdbcDatabase);
DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase);
}
};
InputMethodListener portInputMethodListener = new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) {
event.consume();
}
}
@Override
public void caretPositionChanged(InputMethodEvent event) {
}
};
DocumentListener updateParaListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void removeUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void changedUpdate(DocumentEvent e) {
updatePara();
}
};
public JDBCDefPane() { public JDBCDefPane() {
initMap();
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
@ -115,7 +275,14 @@ public class JDBCDefPane extends JPanel {
} }
dbtypeComboBox.addActionListener(dbtypeActionListener); dbtypeComboBox.addActionListener(dbtypeActionListener);
dbtypeComboBox.setMaximumRowCount(10); dbtypeComboBox.setMaximumRowCount(10);
driverLoaderBox = new UIComboBox();
refreshDriverLoader();
driverLoaderBox.setEditable(false);
driverManageBox = new UIComboBox();
refreshDriverManage(true);
driverManageBox.setEditable(false);
driverManageBox.addActionListener(driverManageListener);
driverLoaderBox.setVisible(isSelfDefine());
driverComboBox = new UIComboBox(); driverComboBox = new UIComboBox();
driverComboBox.setEditable(true); driverComboBox.setEditable(true);
driverComboBox.addActionListener(driverListener); driverComboBox.addActionListener(driverListener);
@ -155,17 +322,39 @@ public class JDBCDefPane extends JPanel {
_gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1); _gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1);
} }
}; };
odbcTipsPane.add(odbcTipsLink);
odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(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() {
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help");
BrowseUtils.browser(url); BrowseUtils.browser(url);
} }
}); });
driverManageLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")) {
@Override
public void paintComponent(Graphics _gfx) {
super.paintComponent(_gfx);
_gfx.setColor(Color.blue);
_gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1);
}
};
driverManageLabel.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")), driverManageLabel.getPreferredSize().height));
driverManageLabel.setVisible(isSelfDefine());
driverManageLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("driver.add.help");
BrowseUtils.browser(url);
}
});
odbcTipsPane.add(driverManageLabel);
odbcTipsPane.add(odbcTipsLink);
JPanel driverComboBoxAndTips = new JPanel(new BorderLayout()); JPanel driverComboBoxAndTips = new JPanel(new BorderLayout());
driverComboBoxAndTips.add(driverComboBox, BorderLayout.WEST); JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
normalFlowInnerContainer_s_pane.add(driverManageBox);
normalFlowInnerContainer_s_pane.add(driverComboBox);
normalFlowInnerContainer_s_pane.add(driverLoaderBox);
driverComboBoxAndTips.add(normalFlowInnerContainer_s_pane, BorderLayout.WEST);
driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER); driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER);
JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
@ -225,7 +414,70 @@ public class JDBCDefPane extends JPanel {
innerthis.add(centerPanel); innerthis.add(centerPanel);
} }
private void initMap() {
Map<String, DriverLoader> driverLoaders = DriverLoaderConfig.getInstance().getDriverLoaders();
nameAndRepresent = getDriverLoaderAndRepresent(driverLoaders);
}
private HashBiMap<String, String> getDriverLoaderAndRepresent(Map<String, DriverLoader> driverLoaders) {
HashBiMap<String, String> driverHashBiMap = HashBiMap.create();
if (WorkContext.getCurrent().isWarDeploy()) {
return driverHashBiMap;
}
// name 是唯一的,name+driver自然也是唯一的
for (DriverLoader driverLoader : driverLoaders.values()) {
driverHashBiMap.put(driverLoader.getName(), getRepresent(driverLoader.getDriverClass(), driverLoader.getName()));
}
return driverHashBiMap;
}
protected JDBCDatabaseConnection getJDBCDatabase() {
return this.jdbcDatabase;
}
private void changePane(Object dbType) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f, 22};
if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) {
if (this.centerPanel.getComponentCount() != partComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(partComponents, new double[]{p, p, p, p, p}, columnSize, centerPanel);
}
} else if (this.centerPanel.getComponentCount() != allComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(allComponents, new double[]{p, p, p, p, p, p, p, p}, columnSize, centerPanel);
}
}
private String getRepresent(String driverClass, String driverName) {
return driverClass + "(" + driverName + ")";
}
private boolean isSelfDefine() {
return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"), driverManageBox.getSelectedItem());
}
private void refreshDriverLoader() {
Set<String> representSet = nameAndRepresent.values();
driverLoaderBox.clearBoxItems();
for (String represent : representSet) {
driverLoaderBox.addItem(represent);
}
}
private void refreshDriverManage(boolean addSelfDefine) {
driverManageBox.clearBoxItems();
driverManageBox.addItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Default"));
if (addSelfDefine) {
driverManageBox.addItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"));
}
}
public void populate(JDBCDatabaseConnection jdbcDatabase) { public void populate(JDBCDatabaseConnection jdbcDatabase) {
// 单例对象,重新打开的时候并不会新建,但是由于driverloaderbox里面需要是动态内容,因此需要进行刷新动作
initMap();
refreshDriverLoader();
needRefresh = false; needRefresh = false;
if (jdbcDatabase == null) { if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection(); jdbcDatabase = new JDBCDatabaseConnection();
@ -256,7 +508,24 @@ public class JDBCDefPane extends JPanel {
} }
} }
this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity());
// jdbcDatabase.getDriverSource() 只会是空或者是有值,但是为了保险起见,还是应该做个处理
String driverSource = jdbcDatabase.getDriverSource();
if (driverSource == null) {
driverSource = StringUtils.EMPTY;
}
if (driverSource.isEmpty()) {
refreshDriverManage(!nameAndRepresent.isEmpty());
this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Default"));
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
} else {
refreshDriverManage(true);
this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"));
String represent = getRepresent(jdbcDatabase.getDriver(), jdbcDatabase.getDriverSource());
if (!nameAndRepresent.containsValue(represent)) {
this.driverLoaderBox.addItem(represent);
}
this.driverLoaderBox.setSelectedItem(represent);
}
this.urlTextField.setText(jdbcDatabase.getURL()); this.urlTextField.setText(jdbcDatabase.getURL());
this.userNameTextField.setText(jdbcDatabase.getUser()); this.userNameTextField.setText(jdbcDatabase.getUser());
this.passwordTextField.setText(jdbcDatabase.getPassword()); this.passwordTextField.setText(jdbcDatabase.getPassword());
@ -269,31 +538,10 @@ public class JDBCDefPane extends JPanel {
needRefresh = false; needRefresh = false;
} }
protected JDBCDatabaseConnection getJDBCDatabase() {
return this.jdbcDatabase;
}
private void changePane(Object dbType) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f, 22};
if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) {
if (this.centerPanel.getComponentCount() != partComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(partComponents, new double[]{p, p, p, p, p}, columnSize, centerPanel);
}
} else if (this.centerPanel.getComponentCount() != allComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(allComponents, new double[]{p, p, p, p, p, p, p, p}, columnSize, centerPanel);
}
}
public JDBCDatabaseConnection update() { public JDBCDatabaseConnection update() {
if (jdbcDatabase == null) { if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection(); jdbcDatabase = new JDBCDatabaseConnection();
} }
Object driveItem = this.driverComboBox.getSelectedItem();
jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString().trim());
jdbcDatabase.setURL(this.urlTextField.getText().trim()); jdbcDatabase.setURL(this.urlTextField.getText().trim());
jdbcDatabase.setUser(this.userNameTextField.getText().trim()); jdbcDatabase.setUser(this.userNameTextField.getText().trim());
jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim()); jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim());
@ -305,126 +553,30 @@ public class JDBCDefPane extends JPanel {
jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK); jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK);
jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem())); jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem()));
} }
return jdbcDatabase; String driverLoader = (String) this.driverLoaderBox.getSelectedItem();
} if (driverLoader == null) {
driverLoader = StringUtils.EMPTY;
ActionListener dbtypeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
urlTextField.setText(StringUtils.EMPTY);
driverComboBox.removeAllItems();
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
driverComboBox.setSelectedItem(StringUtils.EMPTY);
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
driverComboBox.addItem(dus[i].getDriver());
if (i == 0) {
driverComboBox.setSelectedItem(dus[i].getDriver());
urlTextField.setText(dus[i].getURL());
}
}
// 更改数据库类型后 数据库名称置空和之前逻辑保持一致
if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem());
JDBCConnectionDef.getInstance().setConnection((String) dbtypeComboBox.getSelectedItem(), jdbcDatabase);
DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase);
}
};
ActionListener driverListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
urlTextField.setText(dus[i].getURL());
return;
}
}
} }
if (isSelfDefine()) {
String[] split = driverLoader.split("\\(");
if (split.length > 1) {
String name = split[1];
if (name.length() > 0) {
jdbcDatabase.setDriverSource(name.substring(0, name.length() - 1));
} else {
jdbcDatabase.setDriverSource(StringUtils.EMPTY);
} }
} else {
}; jdbcDatabase.setDriverSource(StringUtils.EMPTY);
ActionListener dbtypeButtonActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(driverComboBox.getSelectedItem(), (dus[i].getDriver()))) {
urlTextField.setText(dus[i].getURL());
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) {
// ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
File selectedfile = null;
if (result == JFileChooser.APPROVE_OPTION) {
selectedfile = filechooser.getSelectedFile();
if (selectedfile != null) {
String selectedName = selectedfile.getPath().substring(selectedfile.getPath().lastIndexOf('.') + 1);
if (selectedName.equalsIgnoreCase("mdb") || selectedName.equalsIgnoreCase("accdb")) {
urlTextField.setText(urlTextField.getText() + selectedfile.getPath());
}
}
}
}
break;
}
}
}
};
InputMethodListener portInputMethodListener = new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) {
event.consume();
}
}
@Override
public void caretPositionChanged(InputMethodEvent event) {
}
};
DocumentListener updateParaListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updatePara();
} }
jdbcDatabase.setDriver(split[0]);
@Override } else {
public void removeUpdate(DocumentEvent e) { Object driveItem = this.driverComboBox.getSelectedItem();
updatePara(); jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString().trim());
jdbcDatabase.setDriverSource(StringUtils.EMPTY);
} }
return jdbcDatabase;
@Override
public void changedUpdate(DocumentEvent e) {
updatePara();
} }
};
private void updatePara() { private void updatePara() {
String dbType = dbtypeComboBox.getSelectedItem().toString(); String dbType = dbtypeComboBox.getSelectedItem().toString();
@ -489,21 +641,6 @@ public class JDBCDefPane extends JPanel {
this.hostTextField.getDocument().removeDocumentListener(updateURLListener); this.hostTextField.getDocument().removeDocumentListener(updateURLListener);
} }
KeyListener portKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String port = portTextField.getText();
if (isPortValid(port)) {
updateURL();
} else {
portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , ""));
if (!isPortValid(portTextField.getText())) {
portTextField.setText(StringUtils.EMPTY);
updateURL();
}
}
}
};
private boolean isPortValid(String port) { private boolean isPortValid(String port) {
return PORT.matcher(port).find(); return PORT.matcher(port).find();

303
designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java

@ -0,0 +1,303 @@
package com.fr.design.data.datapane.preview;
import com.fr.design.base.clipboard.ClipboardHelper;
import com.fr.design.gui.itable.SortableJTable;
import com.fr.design.gui.itable.TableSorter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class CopyableJTable extends SortableJTable {
//区域选中用到的定位数据
public int startRow = -1;
public int startCol = -1;
public int endRow = -1;
public int endCol = -1;
//单元格不连续多选用到的定位数据
java.util.List<Point> pointList = new ArrayList<>();
//shift键是否被按下
public boolean isShiftDown = false;
//control\command键是否被按下
public boolean isControlDown = false;
//是否可以复制
public boolean isCopy = true;
int ctrlKeyCode = 17;
int cKeyCode = 67;
int shiftKeyCode = 16;
int commandKeyCode = 157;
//选中单元格的背景色
Color selectBackGround = new Color(54, 133, 242, 63);
Color headerBackGround = new Color(229, 229, 229);
boolean mouseDrag = false;
boolean headerSelect = false;
DefaultTableCellRenderer tableHeaderCellRenderer = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(headerBackGround);
}
return comp;
}
};
public CopyableJTable(TableSorter tableModel) {
super(tableModel);
initListener();
this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer);
}
private void initListener() {
CopyableJTable self = this;
this.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
if (mouseDrag) {
headerSelect = true;
int column = getColumn(e);
self.updateEndPoint(-1, column);
self.getTableHeader().repaint();
}
}
@Override
public void mouseExited(MouseEvent e) {
if (mouseDrag) {
headerSelect = false;
}
}
@Override
public void mouseClicked(MouseEvent e) {
headerSelect = true;
int column = getColumn(e);
if (column != -1) {
self.clearPoint();
self.addPoint(-1, column);
self.updateStartPoint(-1, column);
self.updateEndPoint(-1, column);
self.refreshTable();
}
}
private int getColumn(MouseEvent e) {
JTableHeader h = (JTableHeader) e.getSource();
TableColumnModel columnModel = h.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
return viewColumn;
}
});
this.getTableHeader().addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
@Override
public void mouseDragged(MouseEvent e) {
self.clearPoint();
self.updateStartPoint(-1, -1);
self.updateEndPoint(-1, -1);
self.refreshTable();
}
});
this.addMouseMotionListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseDragged(MouseEvent evt) {
mouseDrag = true;
int row = self.rowAtPoint(evt.getPoint());
int col = self.columnAtPoint(evt.getPoint());
if (self.updateEndPoint(row, col)) {
self.refreshTable();
}
}
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
});
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
headerSelect = false;
int row = self.rowAtPoint(e.getPoint());
int col = self.columnAtPoint(e.getPoint());
if (!self.isControlDown) {
self.clearPoint();
}
if (self.isShiftDown) {
self.clearPoint();
} else {
self.updateStartPoint(row, col);
}
self.addPoint(row, col);
self.updateEndPoint(row, col);
self.refreshTable();
}
});
this.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (isControlKey(e)) {
isControlDown = true;
} else if (e.getKeyCode() == shiftKeyCode) {
isShiftDown = true;
} else if (e.getKeyCode() == cKeyCode) {
if (isControlDown && isCopy) {
self.copy();
isCopy = false;
}
}
}
@Override
public void keyReleased(KeyEvent e) {
if (isControlKey(e)) {
isControlDown = false;
isCopy = true;
} else if (e.getKeyCode() == shiftKeyCode) {
isShiftDown = false;
}
}
private boolean isControlKey(KeyEvent e) {
if (e.getKeyCode() == ctrlKeyCode) {
return true;
}
if (e.getKeyCode() == commandKeyCode && OperatingSystem.isMacos()) {
return true;
}
return false;
}
});
}
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component comp = super.prepareRenderer(renderer, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(this.getBackground());
}
return comp;
}
private boolean updateEndPoint(int row, int col) {
if (headerSelect && row != -1)
return false;
if (endRow != row || endCol != col) {
endRow = row;
endCol = col;
return true;
}
return false;
}
private boolean updateStartPoint(int row, int col) {
if (startRow != row || startCol != col) {
startRow = row;
startCol = col;
return true;
}
return false;
}
private void addPoint(int row, int col) {
pointList.add(new Point(row, col));
}
private void clearPoint() {
pointList = new ArrayList<>();
}
private void copy() {
FineLoggerFactory.getLogger().info("copy cell value");
java.util.List<java.util.List<Object>> table = new ArrayList<>();
if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) {
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) {
table.add(new ArrayList<>());
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) {
Object text = this.getTableValue(i, j);
table.get(table.size() - 1).add(text);
}
}
} else if (pointList.size() > 0) {
Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY));
int startRow = pointList.get(0).x;
int currentRow = startRow;
table.add(new ArrayList<>());
for (Point point : pointList) {
while (currentRow < point.x) {
table.add(new ArrayList<>());
currentRow++;
}
Object text = this.getTableValue(point.x, point.y);
table.get(table.size() - 1).add(text);
}
}
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table));
clip.setContents(tText, null);
}
private Object getTableValue(int row, int col) {
Object value = null;
if (col > -1) {
if (row > -1) {
value = this.getValueAt(row, col);
} else if (row == -1) {
col = columnModel.getColumn(col).getModelIndex();
value = this.getModel().getColumnName(col);
}
}
return value;
}
private void refreshTable() {
this.repaint();
this.getTableHeader().repaint();
}
private boolean isChoose(int row, int col) {
if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) {
if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) {
return true;
}
}
for (Point point : pointList) {
if (point.x == row && point.y == col) {
return true;
}
}
return false;
}
}

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

@ -26,7 +26,6 @@ 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.design.ui.util.UIUtil;
import com.fr.design.utils.gui.GUICoreUtils;
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;
@ -162,7 +161,7 @@ public class PreviewTablePane extends BasicPane {
} }
}); });
preveiwTable = new SortableJTable(new TableSorter()); preveiwTable = new CopyableJTable(new TableSorter());
preveiwTable.setRowSelectionAllowed(false); preveiwTable.setRowSelectionAllowed(false);
preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

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

@ -410,6 +410,4 @@ public abstract class BasicPane extends JPanel {
} }
} }
} }

12
designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java

@ -3,6 +3,7 @@ package com.fr.design.dialog;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -10,6 +11,7 @@ import com.fr.design.notification.Notification;
import com.fr.design.notification.NotificationCenter; import com.fr.design.notification.NotificationCenter;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -40,9 +42,17 @@ public class NotificationDialog extends JDialog {
private UILabel messageText; private UILabel messageText;
private NotificationDialogAction notificationDialogAction; private NotificationDialogAction notificationDialogAction;
private ScheduledExecutorService TIMER; private ScheduledExecutorService TIMER;
private Dimension dialogSize = new Dimension(230, 95);
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) { public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) {
this(owner, title, isModal, messageType, message, action, null);
}
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action, Dimension dimension) {
super(owner); super(owner);
if (dimension != null) {
this.dialogSize = dimension;
}
setTitle(title); setTitle(title);
initComponents(StringUtils.EMPTY, messageType, message, isModal, action); initComponents(StringUtils.EMPTY, messageType, message, isModal, action);
} }
@ -77,7 +87,7 @@ public class NotificationDialog extends JDialog {
JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane.setBorder(BorderFactory.createEmptyBorder()); jScrollPane.setBorder(BorderFactory.createEmptyBorder());
centerPanel.add(jScrollPane, BorderLayout.CENTER); centerPanel.add(jScrollPane, BorderLayout.CENTER);
centerPanel.setPreferredSize(new Dimension(230, 95)); centerPanel.setPreferredSize(dialogSize);
body.add(centerPanel, BorderLayout.CENTER); body.add(centerPanel, BorderLayout.CENTER);
//查看详情 //查看详情

251
designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java

@ -0,0 +1,251 @@
package com.fr.design.dialog;
import com.fr.base.GraphHelper;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* 带链接的错误详情弹窗
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/2
*/
public class UIDetailErrorLinkDialog extends UIDialog {
private static final Color LINK_COLOR = new Color(51, 152, 253);
private static final int GAP_5 = 5;
private static final int GAP_10 = 10;
private static final String TAG_A_START = "<a>";
private static final String TAG_A_END = "</a>";
private static final double SCALE = 1.2;
private final Dimension dimension = new Dimension(300, 180);
public static Builder newBuilder() {
return new Builder();
}
private UIDetailErrorLinkDialog(Frame parent, Builder builder) {
super(parent);
init(builder);
}
private UIDetailErrorLinkDialog(Dialog parent, Builder builder) {
super(parent);
init(builder);
}
private void init(Builder builder) {
this.setTitle(builder.title);
// 顶部 图标和提示
UILabel errorIcon = new UILabel(IOUtils.readIcon("com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png"));
UILabel errorInfo= new UILabel(builder.reason);
JPanel topPane = new JPanel(new FlowLayout(FlowLayout.LEFT, GAP_10, GAP_5));
topPane.add(errorIcon);
topPane.add(errorInfo);
// 中部 详细内容
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(0, GAP_5,0,0));
UILabel errorCodeLabel = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Error_Code", builder.errorCode));
UILabel link = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Show_Error_Stack"));
link.setForeground(LINK_COLOR);
link.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
StringWriter stackTraceWriter = new StringWriter();
builder.throwable.printStackTrace(new PrintWriter(stackTraceWriter));
StackPane stackPane = new StackPane(stackTraceWriter.toString());
BasicDialog dialog = stackPane.showLargeWindow(UIDetailErrorLinkDialog.this, null);
dialog.setVisible(true);
}
});
contentPane.add(errorCodeLabel, BorderLayout.NORTH);
contentPane.add(createComponent(builder), BorderLayout.CENTER);
contentPane.add(link, BorderLayout.SOUTH);
// 确定 + 取消
JPanel actionPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, GAP_10, GAP_10));
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Report_OK")));
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")));
this.getContentPane().add(topPane, BorderLayout.NORTH);
this.getContentPane().add(contentPane, BorderLayout.CENTER);
this.getContentPane().add(actionPane, BorderLayout.SOUTH);
this.setSize(dimension);
this.setResizable(false);
this.setModal(true);
GUICoreUtils.centerWindow(this);
}
private UIButton createButton(String content) {
UIButton button = new UIButton(content);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UIDetailErrorLinkDialog.this.dispose();
}
});
return button;
}
private JComponent createComponent(Builder builder) {
JPanel panel = new JPanel(new BorderLayout());
boolean existDetailReason = StringUtils.isNotEmpty(builder.detailReason);
int maxWidth = dimension.width;
if (existDetailReason) {
String message = Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.detailReason);
UILabel label = new UILabel(message);
maxWidth = Math.max(maxWidth, GraphHelper.getWidth(message, label.getFont()));
panel.add(label, BorderLayout.NORTH);
}
String solution = existDetailReason ? builder.solution : Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.solution);
if (builder.solution.contains(TAG_A_START)) {
String[] solutionP1 = solution.split(TAG_A_START);
String[] solutionP2 = solutionP1[1].split(TAG_A_END);
MessageWithLink messageWithLink;
if (solutionP2.length == 2) {
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link, solutionP2[1]);
} else {
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link);
}
panel.add(messageWithLink, BorderLayout.CENTER);
} else {
UILabel solutionLabel = new UILabel(solution);
panel.add(solutionLabel, BorderLayout.CENTER);
}
dimension.width = getMaxDimensionWidth(maxWidth, solution);
return panel;
}
private int getMaxDimensionWidth(int width, String solution) {
int maxWidth = GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont());
if (maxWidth >= width) {
maxWidth = (int) (SCALE * maxWidth);
} else {
maxWidth = width;
}
return maxWidth;
}
@Override
public void checkValid() throws Exception {
// do nothing
}
class StackPane extends BasicPane {
public StackPane(String stack) {
setLayout(new BorderLayout());
UITextArea textArea = new UITextArea();
textArea.setEditable(false);
textArea.setText(stack);
UIScrollPane scrollPane = new UIScrollPane(textArea);
add(scrollPane);
// 滚动条默认在顶部
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scrollPane.getViewport().setViewPosition(new Point(0, 0));
}
});
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine_Design_Basic_Error_Stack");
}
}
public static class Builder {
private Window window;
private String title;
private String reason;
private String errorCode;
private String detailReason;
private String solution;
private String link;
private Throwable throwable;
private Builder() {
}
public Builder setTitle(String title) {
this.title = title;
return this;
}
public Builder setReason(String reason) {
this.reason = reason;
return this;
}
public Builder setErrorCode(String errorCode) {
this.errorCode = errorCode;
return this;
}
public Builder setSolution(String solution) {
this.solution = solution;
return this;
}
public Builder setDetailReason(String detailReason) {
this.detailReason = detailReason;
return this;
}
public Builder setThrowable(Throwable throwable) {
this.throwable = throwable;
return this;
}
public Builder setWindow(Window window) {
this.window = window;
return this;
}
public Builder setLink(String link) {
this.link = link;
return this;
}
public UIDetailErrorLinkDialog build() {
if (this.window instanceof Frame) {
return new UIDetailErrorLinkDialog((Frame) window, this);
} else {
return new UIDetailErrorLinkDialog((Dialog) window, this);
}
}
}
}

2
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java vendored

@ -15,5 +15,5 @@ public interface DesignerWorkspaceInfo extends XMLable {
WorkspaceConnectionInfo getConnection(); WorkspaceConnectionInfo getConnection();
boolean checkValid(); boolean checkValid() throws Exception;
} }

2
designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java vendored

@ -86,6 +86,8 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
return false; return false;
} }
return true; return true;
} }
} }

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

@ -168,8 +168,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override @Override
public boolean checkValid() { public boolean checkValid() throws Exception {
boolean result = false;
String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort()); String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
if (!ComparatorUtils.equals(port, newPort)) { if (!ComparatorUtils.equals(port, newPort)) {
// 使用过程中 更改了内置服务器端口 重新初始化下 // 使用过程中 更改了内置服务器端口 重新初始化下
@ -177,15 +176,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
} }
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 false;
} }
try {
WorkContext.getConnector().validateVT(connection); WorkContext.getConnector().validateVT(connection);
result = true; return true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return result;
}
return result;
} }
} }

16
designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java

@ -0,0 +1,16 @@
package com.fr.design.gui.chart;
import com.fr.chart.chartattr.ChartCollection;
import java.util.EventListener;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/5/26
*/
public interface ChartEditPaneActionListener extends EventListener {
void attributeChange(ChartCollection chartCollection);
}

6
designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java

@ -10,4 +10,10 @@ public interface ChartEditPaneProvider {
void fire(); void fire();
default void addChartEditPaneActionListener(ChartEditPaneActionListener l) {
}
default void removeChartEditPaneActionListener(ChartEditPaneActionListener l) {
}
} }

13
designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java

@ -10,6 +10,7 @@ import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -76,9 +77,12 @@ class JControlUpdatePane extends JPanel {
cardPane.add(updatePanes[i], String.valueOf(i)); cardPane.add(updatePanes[i], String.valueOf(i));
} }
card.show(cardPane, String.valueOf(i)); card.show(cardPane, String.valueOf(i));
try{ try {
if (ob2Populate instanceof Listener) {
listControlPane.wrapperListener((Listener) ob2Populate);
}
updatePanes[i].populateBean(ob2Populate); updatePanes[i].populateBean(ob2Populate);
}catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
break; break;
@ -103,12 +107,15 @@ class JControlUpdatePane extends JPanel {
if (pane != null && pane.isVisible()) { if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean(); Object bean = pane.updateBean();
try { try {
if (bean instanceof Listener) {
listControlPane.wrapperListener((Listener) bean);
}
if (bean instanceof RemoteDesignerWorkspaceInfo) { if (bean instanceof RemoteDesignerWorkspaceInfo) {
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName());
String remindTime = info.getRemindTime(); String remindTime = info.getRemindTime();
((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime);
} }
}catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().info("remindTime is not exist"); FineLoggerFactory.getLogger().info("remindTime is not exist");
} }
if (i < creators.length) { if (i < creators.length) {

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

@ -6,6 +6,7 @@ import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
@ -417,4 +418,10 @@ public abstract class JListControlPane extends JControlPane implements ListContr
public JControlUpdatePane getControlUpdatePane() { public JControlUpdatePane getControlUpdatePane() {
return (JControlUpdatePane) controlUpdatePane; return (JControlUpdatePane) controlUpdatePane;
} }
@Override
public void wrapperListener(Listener listener){
}
} }

3
designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java

@ -3,6 +3,7 @@ package com.fr.design.gui.controlpane;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.form.event.Listener;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
@ -32,4 +33,6 @@ public interface ListControlPaneProvider extends UnrepeatedNameHelper {
void showSelectPane(); void showSelectPane();
void showEditPane(); void showEditPane();
ShortCut4JControlPane[] getShorts(); ShortCut4JControlPane[] getShorts();
void wrapperListener(Listener listener);
} }

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

@ -6,6 +6,7 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.UINameEdList; import com.fr.design.gui.ilist.UINameEdList;
import com.fr.form.event.Listener;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
@ -314,4 +315,10 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon
public JNameEdList getNameableList() { public JNameEdList getNameableList() {
return nameableList; return nameableList;
} }
@Override
public void wrapperListener(Listener listener){
}
} }

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

@ -391,7 +391,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
@Override @Override
public Nameable[] update() { public Nameable[] update() {
java.util.List<Nameable> res = new java.util.ArrayList<Nameable>(); List<Nameable> res = new ArrayList<Nameable>();
getControlUpdatePane().update(); getControlUpdatePane().update();
Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator(); Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -516,6 +516,11 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@Override
public void wrapperListener(Listener listener){
}
private class ListWrapperPane extends JPanel { private class ListWrapperPane extends JPanel {
private UINameEdList nameEdList; private UINameEdList nameEdList;

2
designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java

@ -46,9 +46,11 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
protected void initContentPane() { protected void initContentPane() {
leftContentPane = createContentPane(); leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original)); leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original));
this.add(leftContentPane, BorderLayout.CENTER); this.add(leftContentPane, BorderLayout.CENTER);
} }
}
protected abstract JPanel createContentPane(); protected abstract JPanel createContentPane();

63
designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java

@ -0,0 +1,63 @@
package com.fr.design.gui.ibutton;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
public class UIHead {
private String text = StringUtils.EMPTY;
private Icon icon = null;
private boolean enable = true;
private int index = 0;
public UIHead(String text, int index) {
this.text = text;
this.index = index;
}
public UIHead(String text, int index, boolean enable) {
this(text, index);
this.enable = enable;
}
public UIHead(Icon icon, int index) {
this.icon = icon;
this.index = index;
}
public UIHead(Icon icon, int index, boolean enable) {
this(icon, index);
this.enable = enable;
}
public UIHead(String text, Icon icon, int index) {
this.text = text;
this.icon = icon;
this.index = index;
}
public UIHead(String text, Icon icon, int index, boolean enable) {
this(text, icon, index);
this.enable = enable;
}
public boolean isOnlyText() {
return StringUtils.isNotEmpty(text) && icon == null;
}
public String getText() {
return text;
}
public Icon getIcon() {
return icon;
}
public boolean isEnable() {
return enable;
}
public int getIndex() {
return index;
}
}

129
designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java

@ -10,7 +10,6 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -18,8 +17,10 @@ import java.awt.event.MouseListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
// fanglei:不是原作者,只是优化如下问题:代码冗余,无法拓展(例如我想加个enable属性没法加),甚至还有数组越界的问题。
public class UIHeadGroup extends JPanel { public class UIHeadGroup extends JPanel {
private static final int MIN_HEIGHT = 25; private static final int MIN_HEIGHT = 25;
private List<UIHead> uiHeads = new ArrayList<>();
protected List<UIToggleButton> labelButtonList; protected List<UIToggleButton> labelButtonList;
private boolean isNeedLeftRightOutLine = true; private boolean isNeedLeftRightOutLine = true;
protected int selectedIndex = -1; protected int selectedIndex = -1;
@ -29,77 +30,47 @@ public class UIHeadGroup extends JPanel {
} }
public UIHeadGroup(String[] textArray) { public UIHeadGroup(String[] textArray) {
labelButtonList = new ArrayList<UIToggleButton>(textArray.length);
this.setBackground(UIConstants.TREE_BACKGROUND);
this.setLayout(new GridLayout(0, textArray.length, 0, 0));
for (int i = 0; i < textArray.length; i++) { for (int i = 0; i < textArray.length; i++) {
final int index = i; uiHeads.add(new UIHead(textArray[i], i));
String text = textArray[i];
final UIToggleButton labelButton = new UIToggleButton(text) {
@Override
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
setSelectedIndex(index);
UIHeadGroup.this.repaint();
} }
}; initUIHeadGroup(uiHeads);
}
};
initButton(labelButton);
}
setSelectedIndex(0);
} }
public UIHeadGroup(Icon[] iconArray) { public UIHeadGroup(Icon[] iconArray) {
labelButtonList = new ArrayList<UIToggleButton>(iconArray.length);
this.setBackground(UIConstants.NORMAL_BACKGROUND);
this.setLayout(new GridLayout(0, iconArray.length, 1, 0));
for (int i = 0; i < iconArray.length; i++) { for (int i = 0; i < iconArray.length; i++) {
final int index = i; uiHeads.add(new UIHead(iconArray[i], i));
Icon icon = iconArray[i];
final UIToggleButton labelButton = new UIToggleButton(icon) {
@Override
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
setSelectedIndex(index);
UIHeadGroup.this.repaint();
} }
}; initUIHeadGroup(uiHeads);
} }
};
initButton(labelButton); public UIHeadGroup(Icon[] iconArray, String[] textArray) {
int length = Math.min(textArray.length, iconArray.length);
for (int i = 0; i < length; i++) {
uiHeads.add(new UIHead(textArray[i], iconArray[i], i));
} }
setSelectedIndex(0); initUIHeadGroup(uiHeads);
} }
public UIHeadGroup(Icon[] iconArray, String[] textArray) { public UIHeadGroup(List<UIHead> uiHeads) {
labelButtonList = new ArrayList<UIToggleButton>(Math.min(textArray.length, iconArray.length)); initUIHeadGroup(uiHeads);
this.setBackground(UIConstants.NORMAL_BACKGROUND);
this.setLayout(new GridLayout(0, textArray.length, 1, 0));
for (int i = 0; i < textArray.length; i++) {
final int index = i;
String text = textArray[i];
Icon icon = iconArray[i];
final UIToggleButton labelButton = new UIToggleButton(text, icon) {
@Override
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
setSelectedIndex(index);
UIHeadGroup.this.repaint();
} }
};
public void initUIHeadGroup(List<UIHead> uiHeads) {
if (uiHeads != null) {
labelButtonList = new ArrayList<UIToggleButton>(uiHeads.size());
this.setLayout(new GridLayout(0, uiHeads.size(), 1, 0));
for (UIHead head : uiHeads) {
if (head.isOnlyText()) {
this.setBackground(UIConstants.TREE_BACKGROUND);
} else {
this.setBackground(UIConstants.NORMAL_BACKGROUND);
} }
}; initButton(createUIToggleButton(head));
initButton(labelButton);
} }
setSelectedIndex(0); setSelectedIndex(0);
} }
}
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
@ -110,32 +81,6 @@ public class UIHeadGroup extends JPanel {
return dim; return dim;
} }
@Override
protected void paintBorder(Graphics g) {
// Graphics2D g2d = (Graphics2D)g;
// g2d.setColor(UIConstants.LINE_COLOR);
//
// int width = 0;
// for(int i = 0; i < labelButtonList.size() - 1; i++) {
// int height = labelButtonList.get(i).getHeight();
// width += labelButtonList.get(i).getWidth() + 1;
// g.drawLine(width, 0, width, height);
// }
//
// width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1;
// if(isNeedLeftRightOutLine) {
// g2d.drawRect(0, 0, width, getHeight() - 1);
// } else {
// g2d.drawLine(1, 0, width - 1, 0);
// g2d.drawLine(1, getHeight() - 1, width - 1, getHeight() - 1);
// }
//
//
// g2d.setColor(UIConstants.NORMAL_BACKGROUND);
// UIToggleButton headButton = labelButtonList.get(selectedIndex);
// g2d.drawLine(headButton.getX(), headButton.getHeight() + 1, headButton.getX() + headButton.getWidth() - 1, headButton.getHeight() + 1);
}
private void initButton(UIToggleButton labelButton) { private void initButton(UIToggleButton labelButton) {
labelButton.setRoundBorder(false); labelButton.setRoundBorder(false);
labelButton.setBorderPainted(false); labelButton.setBorderPainted(false);
@ -172,6 +117,26 @@ public class UIHeadGroup extends JPanel {
return selectedIndex; return selectedIndex;
} }
public UIToggleButton createUIToggleButton(final UIHead head) {
UIToggleButton uiToggleButton = new UIToggleButton(head.getText(), head.getIcon()) {
@Override
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (head.isEnable()) {
setSelectedIndex(head.getIndex());
UIHeadGroup.this.repaint();
}
}
};
}
};
uiToggleButton.setEnabled(head.isEnable());
return uiToggleButton;
}
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);

103
designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java

@ -1,103 +0,0 @@
package com.fr.design.gui.ifilechooser;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.io.File;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public abstract class AbstractFileChooser {
/**
* 返回当前目录
*
*/
public abstract File getCurrentDirectory();
/**
* 返回当前的文件选择过滤器
*
*/
public abstract FileFilter getFileFilter();
/**
* 返回选择的文件
*
*/
public abstract File getSelectedFile();
/**
* 多文件选择模式下 返回选择的多个文件
*
*/
public abstract File[] getSelectedFiles();
/**
* 是否可以选择多个文件
*
*/
public abstract boolean isMultiSelectionEnabled();
/**
* 设置当前选择的目录
*
*/
public abstract void setCurrentDirectory(File dir);
/**
* 设置左上角标题
*
*/
public abstract void setDialogTitle(String title);
/**
* 设置当前的文件过滤器
*
*/
public abstract void setFileFilter(final FileFilter filter);
/**
* 设置文件选择器模式
*
* JFileChooser.FILES_ONLY
* JFileChooser.DIRECTORIES_ONLY
* JFileChooser.FILES_AND_DIRECTORIES
*/
public abstract void setFileSelectionMode(int selectionMode);
/**
* 设置是否允许选择多个文件
*
*/
public abstract void setMultiSelectionEnabled(boolean multiple);
/**
* 设置选择的文件 用于showSaveDialog
*
*/
public abstract void setSelectedFile(File file);
/**
* 弹出文件选择器 打开文件
*
*/
public abstract int showOpenDialog(Component parent);
/**
* 弹出文件选择器 保存文件
*
*/
public abstract int showSaveDialog(Component parent);
/**
* https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4031440
*
* 设置文件名后缀 起到文件过滤的作用 形如 "*.jpg;*.jpeg"
*
*/
public abstract void setExtensionFilter(String file);
}

12
designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java

@ -0,0 +1,12 @@
package com.fr.design.gui.ifilechooser;
import java.awt.*;
import java.io.File;
public interface FileChooserProvider {
File[] getSelectedFiles();
File getSelectedFile();
int showDialog(Component parent);
}

5
designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java

@ -0,0 +1,5 @@
package com.fr.design.gui.ifilechooser;
public enum FileSelectionMode {
FILE, MULTIPLE_FILE, DIR
}

225
designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java

@ -0,0 +1,225 @@
package com.fr.design.gui.ifilechooser;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.log.FineLoggerFactory;
import com.sun.javafx.application.PlatformImpl;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.paint.Color;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.List;
import java.util.concurrent.CountDownLatch;
public class JavaFxNativeFileChooser implements FileChooserProvider {
private File[] selectedFiles = new File[0];
private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE;
private String title = Toolkit.i18nText("Fine-Design_Basic_Open");
private FileChooser.ExtensionFilter[] filters;
private File currentDirectory;
@Override
public File[] getSelectedFiles() {
return selectedFiles;
}
@Override
public File getSelectedFile() {
if (selectedFiles.length > 0) {
return selectedFiles[0];
}
return null;
}
@Override
public int showDialog(Component parent) {
final CountDownLatch latch = new CountDownLatch(1);
PlatformImpl.startup(() -> {
});
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
Component fileChooserParent = parent;
if (fileChooserParent == null) {
fileChooserParent = DesignerContext.getDesignerFrame();
}
Stage stage = showCoverStage(fileChooserParent);
try {
if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(title);
fileChooser.getExtensionFilters().addAll(filters);
fileChooser.setInitialDirectory(currentDirectory);
if (fileSelectionMode == FileSelectionMode.FILE) {
File file = fileChooser.showOpenDialog(stage);
if (file != null) {
selectedFiles = new File[]{file};
}
} else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) {
List<File> fileList = fileChooser.showOpenMultipleDialog(stage);
if (fileList != null) {
selectedFiles = new File[fileList.size()];
fileList.toArray(selectedFiles);
}
}
} else if (fileSelectionMode == FileSelectionMode.DIR) {
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setTitle(title);
directoryChooser.setInitialDirectory(currentDirectory);
File folder = directoryChooser.showDialog(stage);
if (folder != null) {
selectedFiles = new File[]{folder};
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
} finally {
latch.countDown();
closeCoverStage(stage);
}
}
private void closeCoverStage(Stage stage) {
if (stage != null) {
stage.close();
closeCoverStage((Stage) stage.getOwner());
}
}
private Stage showCoverStage(Component component) {
try {
if (component == null)
return null;
Stage parentStage = showCoverStage(component.getParent());
if (component instanceof JDialog || component instanceof JFrame) {
return createStage(component.getX(), component.getY(), component.getWidth(), component.getHeight(), parentStage);
} else {
return parentStage;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
return null;
}
}
private Stage createStage(double x, double y, double w, double h, Stage parentStage) {
try {
Stage stage = new Stage();
stage.setX(x);
stage.setY(y);
stage.setWidth(w);
stage.setHeight(h);
stage.setOpacity(0.2);
stage.setResizable(false);
stage.initStyle(StageStyle.UNDECORATED);
Label label = new Label();
label.setBackground(
new Background(new BackgroundFill(Color.color(0.78, 0.78, 0.80, 0.5), null, null)));
stage.setScene(new Scene(label));
if (parentStage != null) {
stage.initOwner(parentStage);
stage.initModality(Modality.WINDOW_MODAL);
}
stage.show();
return stage;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
return null;
}
}
});
try {
latch.await();
} catch (InterruptedException ignore) {
}
return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION;
}
public void setSelectionMode(FileSelectionMode fileSelectionMode) {
this.fileSelectionMode = fileSelectionMode;
}
public void setCurrentDirectory(File currentDirectory) {
this.currentDirectory = currentDirectory;
}
public static class Builder {
private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE;
private String title = Toolkit.i18nText("Fine-Design_Basic_Open");
private FileChooser.ExtensionFilter[] filters = new FileChooser.ExtensionFilter[0];
private File currentDirectory;
public Builder fileSelectionMode(FileSelectionMode fileSelectionMode) {
this.fileSelectionMode = fileSelectionMode;
return this;
}
public Builder title(String title) {
this.title = title;
return this;
}
public Builder filters(FileChooser.ExtensionFilter[] filters) {
this.filters = filters;
return this;
}
public Builder filter(String des, String... extensions) {
if (extensions != null) {
this.filters = new FileChooser.ExtensionFilter[]{new FileChooser.ExtensionFilter(des, extensions)};
}
return this;
}
public Builder currentDirectory(File currentDirectory) {
if (currentDirectory != null) {
if (!currentDirectory.isDirectory()) {
currentDirectory = currentDirectory.getParentFile();
}
if (currentDirectory != null && currentDirectory.isDirectory()) {
this.currentDirectory = currentDirectory;
}
}
return this;
}
public Builder currentDirectory(String path) {
if (path != null) {
return currentDirectory(new File(path));
}
return this;
}
public JavaFxNativeFileChooser build() {
return new JavaFxNativeFileChooser(this);
}
}
private JavaFxNativeFileChooser(Builder builder) {
this.fileSelectionMode = builder.fileSelectionMode;
this.title = builder.title;
this.filters = builder.filters;
this.currentDirectory = builder.currentDirectory;
}
}

154
designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java

@ -1,154 +0,0 @@
package com.fr.design.gui.ifilechooser;
import com.fr.design.gui.ifilechooser.AbstractFileChooser;
import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.io.File;
import java.io.FilenameFilter;
/**
* 系统原生风格的文件选择器
*
* jdk问题
* https://bugs.openjdk.java.net/browse/JDK-4811090 不支持文件扩展选择
* https://stackoverflow.com/questions/40713398/filter-not-working-in-filedialog windows下 setFilenameFilter不work
*
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public class UINativeFileChooser extends AbstractFileChooser {
private final FileDialog fileDialog;
private FileFilter fileFilter;
private int selectionMode;
public UINativeFileChooser(File file) {
fileDialog = new FileDialog(DesignerContext.getDesignerFrame());
if (file != null) {
fileDialog.setDirectory(file.getAbsolutePath());
fileDialog.setFile(file.toString());
}
}
public UINativeFileChooser() {
this(null);
}
@Override
public File getCurrentDirectory() {
return new File(fileDialog.getDirectory());
}
@Override
public FileFilter getFileFilter() {
return fileFilter;
}
@Override
public File getSelectedFile() {
return new File(fileDialog.getDirectory() + fileDialog.getFile());
}
@Override
public File[] getSelectedFiles() {
return fileDialog.getFiles();
}
@Override
public boolean isMultiSelectionEnabled() {
return fileDialog.isMultipleMode();
}
@Override
public void setCurrentDirectory(File f) {
fileDialog.setDirectory(f.toString());
}
@Override
public void setDialogTitle(String title) {
fileDialog.setTitle(title);
}
@Override
public void setFileFilter(final FileFilter cff) {
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File Directory, String fileName) {
return cff.accept(new File(Directory.getAbsolutePath() + fileName));
}
};
fileDialog.setFilenameFilter(filter);
fileFilter = cff;
}
@Override
public void setFileSelectionMode(int selectionMode) {
this.selectionMode = selectionMode;
}
@Override
public void setMultiSelectionEnabled(boolean multiple) {
fileDialog.setMultipleMode(multiple);
}
@Override
public void setSelectedFile(File file) {
fileDialog.setDirectory(file.getAbsolutePath());
fileDialog.setFile(file.getName());
}
@Override
public int showOpenDialog(Component parent) {
boolean appleProperty = OperatingSystem.isMacos() && selectionMode == JFileChooser.DIRECTORIES_ONLY;
if (appleProperty) {
System.setProperty("apple.awt.fileDialogForDirectories", "true");
}
try {
fileDialog.setLocale(JComponent.getDefaultLocale());
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setVisible(true);
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
} finally {
if (appleProperty) {
System.setProperty("apple.awt.fileDialogForDirectories", "false");
}
}
}
@Override
public int showSaveDialog(Component parent) {
fileDialog.setLocale(JComponent.getDefaultLocale());
fileDialog.setMode(FileDialog.SAVE);
fileDialog.setVisible(true);
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
}
@Override
public void setExtensionFilter(String file) {
fileDialog.setFile(file);
}
/**
* 确认本地文件选择器是否支持选择模式
* @param selectionMode 选择模式
* @return 是否支持选择模式
*/
public static boolean supportsSelectionMode(int selectionMode) {
switch (selectionMode) {
case JFileChooser.FILES_AND_DIRECTORIES:
return false;
case JFileChooser.DIRECTORIES_ONLY:
return OperatingSystem.isMacos();
case JFileChooser.FILES_ONLY:
default:
return true;
}
}
}

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

@ -12,6 +12,7 @@ import java.awt.Toolkit;
* Date: 13-3-29 * Date: 13-3-29
* Time: 下午12:02 * Time: 下午12:02
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
* fanglei: 这个类名字虽然叫整数输入框但是里面的业务仅支持输入正整数由于被引用的地方太多无法更改知道就行
*/ */
public class UIIntNumberField extends UINumberField { public class UIIntNumberField extends UINumberField {
public void setFieldDocument() { public void setFieldDocument() {

60
designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java

@ -1,16 +1,17 @@
package com.fr.design.javascript; package com.fr.design.javascript;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.frpane.CommitTabbedPane; import com.fr.design.gui.frpane.CommitTabbedPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.js.Commit2DBJavaScript; import com.fr.js.Commit2DBJavaScript;
import com.fr.write.DBManipulation; import com.fr.write.DBManipulation;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -25,26 +26,27 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 构造函数控件事件的提交入库面板 * 构造函数控件事件的提交入库面板
*
* @param javaScriptActionPane JS提交面板对象 * @param javaScriptActionPane JS提交面板对象
* @param dbManipulationPaneList 提交入库的提交面板列表 * @param dbManipulationPaneList 提交入库的提交面板列表
*/ */
public Commit2DBJavaScriptPane(final JavaScriptActionPane javaScriptActionPane, List dbManipulationPaneList) { public Commit2DBJavaScriptPane(final JavaScriptActionPane javaScriptActionPane, List dbManipulationPaneList) {
this.dbmPaneList=dbManipulationPaneList; this.dbmPaneList = dbManipulationPaneList;
this.javaScriptActionPane = javaScriptActionPane; this.javaScriptActionPane = javaScriptActionPane;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
commitTabbedPane = new CommitTabbedPane(this,dbmPaneList); commitTabbedPane = new CommitTabbedPane(this, dbmPaneList);
commitTabbedPane.setPreferredSize(new Dimension(commitTabbedPane.getWidth(),20)); commitTabbedPane.setPreferredSize(new Dimension(commitTabbedPane.getWidth(), 20));
this.add(commitTabbedPane, BorderLayout.NORTH) ; this.add(commitTabbedPane, BorderLayout.NORTH);
cardPane = new JPanel(new CardLayout()); cardPane = new JPanel(new CardLayout());
cardNames = new String[dbmPaneList.size()] ; cardNames = new String[dbmPaneList.size()];
for (int i = 0; i < this.dbmPaneList.size(); i++) { for (int i = 0; i < this.dbmPaneList.size(); i++) {
if(((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null){ if (((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null) {
cardNames[i] = ""; cardNames[i] = "";
} else{ } else {
cardNames[i] =((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName(); cardNames[i] = ((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName();
} }
cardPane.add((DBManipulationPane)this.dbmPaneList.get(i),cardNames[i]); cardPane.add((DBManipulationPane) this.dbmPaneList.get(i), cardNames[i]);
} }
this.add(cardPane, BorderLayout.CENTER); this.add(cardPane, BorderLayout.CENTER);
@ -55,33 +57,33 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
btPane.add(addCallbackButton); btPane.add(addCallbackButton);
} }
/** /**
* 更新DBManipulationPane * 更新DBManipulationPane
*/ */
public void updateCardPane(){ public void updateCardPane() {
cardNames = new String[dbmPaneList.size()] ; cardNames = new String[dbmPaneList.size()];
for (int i = 0; i < this.dbmPaneList.size(); i++) { for (int i = 0; i < this.dbmPaneList.size(); i++) {
if(((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null){ if (((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null) {
cardNames[i] = ""; cardNames[i] = "";
} else{ } else {
cardNames[i] =((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName(); cardNames[i] = ((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName();
} }
cardPane.add((DBManipulationPane)this.dbmPaneList.get(i),cardNames[i]); cardPane.add((DBManipulationPane) this.dbmPaneList.get(i), cardNames[i]);
} }
CardLayout cardLayout = (CardLayout)cardPane.getLayout(); CardLayout cardLayout = (CardLayout) cardPane.getLayout();
cardLayout.show(cardPane,cardNames[commitTabbedPane.getSelectedIndex()]); cardLayout.show(cardPane, cardNames[commitTabbedPane.getSelectedIndex()]);
} }
public void setList(List list){ public void setList(List list) {
this.dbmPaneList = list; this.dbmPaneList = list;
} }
/** /**
* 新建DBManipulationPane * 新建DBManipulationPane
*
* @return 新建的DBManipulationPane * @return 新建的DBManipulationPane
*/ */
public DBManipulationPane createDBManipulationPane(){ public DBManipulationPane createDBManipulationPane() {
DBManipulationPane db = javaScriptActionPane.createDBManipulationPane(); DBManipulationPane db = javaScriptActionPane.createDBManipulationPane();
db.populateBean(null); db.populateBean(null);
dbmPaneList.add(db); dbmPaneList.add(db);
@ -91,6 +93,7 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 窗口名称 * 窗口名称
*
* @return 返回窗口名称 * @return 返回窗口名称
*/ */
public String title4PopupWindow() { public String title4PopupWindow() {
@ -103,10 +106,10 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
public void reset() { public void reset() {
this.javaScriptActionPane.setCall(null); this.javaScriptActionPane.setCall(null);
//重置后只保留,只留第一个tab //重置后只保留,只留第一个tab
while (dbmPaneList.size() > 1){ while (dbmPaneList.size() > 1) {
dbmPaneList.remove(1); dbmPaneList.remove(1);
} }
((DBManipulationPane)dbmPaneList.get(0)).populateBean(null); ((DBManipulationPane) dbmPaneList.get(0)).populateBean(null);
} }
@Override @Override
@ -131,11 +134,15 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 更新数据层JavaBean * 更新数据层JavaBean
*
* @return 返回JavaBean * @return 返回JavaBean
*/ */
public Commit2DBJavaScript updateBean() { public Commit2DBJavaScript updateBean() {
Commit2DBJavaScript commit2dbJavaScript = new Commit2DBJavaScript(); Commit2DBJavaScript commit2dbJavaScript = new Commit2DBJavaScript();
if (javaScriptActionPane.getResourceInfo() != null) {
commit2dbJavaScript.setJsResourceInfo(javaScriptActionPane.getResourceInfo());
}
List dbmaniList = new ArrayList(); List dbmaniList = new ArrayList();
for(int i = 0; i < this.dbmPaneList.size(); i++){ for(int i = 0; i < this.dbmPaneList.size(); i++){
DBManipulationPane dbmpane =(DBManipulationPane)this.dbmPaneList.get(i); DBManipulationPane dbmpane =(DBManipulationPane)this.dbmPaneList.get(i);
@ -154,6 +161,7 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 判断是否是能接受的数据类型 * 判断是否是能接受的数据类型
*
* @param ob 对象 * @param ob 对象
* @return 返回是否是能接受的数据类型 * @return 返回是否是能接受的数据类型
*/ */

453
designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java

@ -0,0 +1,453 @@
package com.fr.design.javascript;
import com.fr.base.BaseFormula;
import com.fr.base.Parameter;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.editor.editor.FormulaEditor;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
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.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.GeneralUtils;
import com.fr.js.ExportJavaScript;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript> {
private ExportRadioGroup templateRadioGroup;
private UIRadioButton currentTemplateRadio;
private UIRadioButton otherTemplateRadio;
private UITextField reportPathTextField;
private UIButton browserButton;
private UIComboBox exportTypeComboBox;
private ExportRadioGroup fileNameRadioGroup;
private UIRadioButton defaultNameRadio;
private UIRadioButton customNameRadio;
private FormulaEditor fileNameFormulaEditor;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
private static final double p = TableLayout.PREFERRED;
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>();
private static final String CURRENT_TEMPLATE = "current";
private static final String DEFAULT_FILENAME = "default";
static {
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_PAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Page"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SIMPLE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Simple"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image"));
}
public ExportJavaScriptPane() {
initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting")));
//导出模板+导出方式+导出文件名
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//导出模板
JPanel chooseTemplatePane = initChooseTemplatePane();
northPane.add(chooseTemplatePane, BorderLayout.NORTH);
//导出方式
JPanel exportTypePane = initExportTypePane();
northPane.add(exportTypePane, BorderLayout.CENTER);
//导出文件名
JPanel fileNamePane = initFileNamePane();
northPane.add(fileNamePane, BorderLayout.SOUTH);
//参数
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel paramsPane = initParamsPane();
centerPane.add(paramsPane);
this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
private JPanel initParamsPane() {
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
parameterViewPane.addTableEditorListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
List<ParameterProvider> list = parameterViewPane.update();
HashSet<String> tempSet = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
if (StringUtils.isEmpty(list.get(i).getName())) {
continue;
}
if (tempSet.contains(list.get(i).toString())) {
list.remove(i);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
return;
}
tempSet.add(list.get(i).toString());
}
}
});
extendParametersCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED);
}
});
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters")));
paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH);
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(parameterViewPane);
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
return paramsPane;
}
private JPanel initFileNamePane() {
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":");
fileNameRadioGroup = new ExportRadioGroup();
defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default"));
defaultNameRadio.setSelected(true);
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom"));
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio);
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
fileNameRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (defaultNameRadio.isSelected()) {
fileNameFormulaEditor.setEnabled(false);
} else {
fileNameFormulaEditor.setEnabled(true);
}
}
});
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}};
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p});
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:red\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>");
fileNameTipPane.add(fileNameTipLabel);
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH);
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER);
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return fileNamePane;
}
private JPanel initExportTypePane() {
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":");
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>());
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel();
String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE};
for (int i = 0; i < allExportTypes.length; i++) {
comboBoxModel.addElement(allExportTypes[i]);
}
this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof String) {
this.setText(EXPORT_TYPES_MAP.get(value));
}
return this;
}
});
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}};
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return exportTypePane;
}
private JPanel initChooseTemplatePane() {
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":");
templateRadioGroup = new ExportRadioGroup();
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"));
currentTemplateRadio.setSelected(true);
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio);
templateRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (currentTemplateRadio.isSelected()) {
reportPathTextField.setEnabled(false);
browserButton.setEnabled(false);
} else {
reportPathTextField.setEnabled(true);
browserButton.setEnabled(true);
}
}
});
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}};
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p});
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(20);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
// 选择路径按钮
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(reportPathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH);
chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER);
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2));
return chooseTemplatePane;
}
@Override
public void populateBean(ExportJavaScript ob) {
if (ob == null) {
ob = new ExportJavaScript();
}
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1);
if (ob.isCurrentTemplate()) {
this.reportPathTextField.setEnabled(false);
this.browserButton.setEnabled(false);
} else {
this.reportPathTextField.setEnabled(true);
this.browserButton.setEnabled(true);
this.reportPathTextField.setText(ob.getTemplatePath());
}
this.exportTypeComboBox.setSelectedItem(ob.getExportType());
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1);
if (ob.isDefaultFileName()) {
this.fileNameFormulaEditor.setEnabled(false);
} else {
this.fileNameFormulaEditor.setEnabled(true);
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName()));
}
if (ob.isExtendParameters()) {
this.extendParametersCheckBox.setSelected(true);
} else {
this.extendParametersCheckBox.setSelected(false);
List<ParameterProvider> parameterList = this.parameterViewPane.update();
parameterList.clear();
ParameterProvider[] parameters = ob.getParameters();
this.parameterViewPane.populate(parameters);
}
}
@Override
public ExportJavaScript updateBean() {
ExportJavaScript exportJavaScript = new ExportJavaScript();
updateBean(exportJavaScript);
return exportJavaScript;
}
@Override
public void updateBean(ExportJavaScript exportJavaScript) {
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected());
exportJavaScript.setTemplatePath(getTemplatePath());
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem()));
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected());
exportJavaScript.setFileName(getFileName());
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected());
if (extendParametersCheckBox.isSelected()) {
exportJavaScript.setParameters(null);
} else {
List<ParameterProvider> parameterList = this.parameterViewPane.update();
if (!parameterList.isEmpty()) {
Parameter[] parameters = new Parameter[parameterList.size()];
parameterList.toArray(parameters);
exportJavaScript.setParameters(parameters);
}
}
}
private String getTemplatePath() {
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText();
}
private String getFileName() {
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText();
}
@Override
public boolean accept(Object ob) {
return ob instanceof ExportJavaScript;
}
@Override
public void reset() {
populateBean(null);
}
@Override
public java.lang.String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
}
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) {
for (UIRadioButton radio : radios) {
buttonGroup.add(radio);
}
}
class ExportRadioGroup extends ButtonGroup {
private List<UIRadioButton> radioButtons = new ArrayList<>();
@Override
public void add(AbstractButton button) {
super.add(button);
UIRadioButton radioButton = (UIRadioButton) button;
radioButtons.add(radioButton);
}
public void selectIndexButton(int index) {
if (index < 0 || index > radioButtons.size() - 1) {
return;
}
UIRadioButton button = radioButtons.get(index);
button.setSelected(true);
}
public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener);
}
}
}
class ReportletPane extends BasicPane {
private TemplateFileTree templateReportletTree;
private JScrollPane t_panel;
private JPanel cardPane;
public ReportletPane() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
centerPane.add(cardPane, BorderLayout.CENTER);
cardPane.setLayout(new CardLayout());
templateReportletTree = new TemplateFileTree();
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt"});
templateReportletTree.setFileNodeFilter(filter);
cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE");
this.refreshEnv();
}
/**
* 检查是否符合规范
*
* @throws Exception 抛错
*/
@Override
public void checkValid() throws Exception {
String path = this.getSelectedReportletPath();
if (path == null) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null"));
}
}
/**
* 刷新Env
*/
public void refreshEnv() {
this.templateReportletTree.refreshEnv();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
}
/*
* 返回选中的Reportlet的路径
*/
public String getSelectedReportletPath() {
if (t_panel.isVisible()) {
return templateReportletTree.getSelectedTemplatePath();
}
return null;
}
/*
* 选中某Reportlet
*/
public void setSelectedReportletPath(String reportletPath) {
if (reportletPath == null) {
return;
}
templateReportletTree.setSelectedTemplatePath(reportletPath);
}
}
}

15
designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java

@ -13,6 +13,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.ui.WebContentUtils; import com.fr.form.ui.WebContentUtils;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.write.JavaScriptResourceInfo;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -30,6 +31,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
private List contentDBManiPane; private List contentDBManiPane;
private JavaScriptResourceInfo resourceInfo;
private JavaScript call = null; private JavaScript call = null;
public JavaScriptActionPane() { public JavaScriptActionPane() {
@ -45,6 +48,10 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
contentDBManiPane.add(createDBManipulationPane()); contentDBManiPane.add(createDBManipulationPane());
paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane)); paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane));
paneList.add(initEmaiPane()); paneList.add(initEmaiPane());
boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
if (workbook) {
paneList.add(new ExportJavaScriptPane());
}
paneList.add(new MobilePopupPane()); paneList.add(new MobilePopupPane());
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG); Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) { if (javaScriptActionProviders != null) {
@ -73,6 +80,14 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
} }
public JavaScriptResourceInfo getResourceInfo() {
return resourceInfo;
}
public void setResourceInfo(JavaScriptResourceInfo resourceInfo) {
this.resourceInfo = resourceInfo;
}
/** /**
* 生成回调函数的按钮 * 生成回调函数的按钮
* *

278
designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java

@ -0,0 +1,278 @@
package com.fr.design.mainframe;
import com.fr.design.DesignState;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import org.jetbrains.annotations.Nullable;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.util.ArrayList;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/4/6
*/
public class CenterRegionContainerPane extends JPanel {
private static volatile CenterRegionContainerPane THIS;
private static final int LEFT_ALIGN_GAP = -5;
private DesktopCardPane centerTemplateCardPane;
private JPanel toolbarPane;//撤销重做 等工具栏 + 模板tab标签 + maybe have cpt 字体
private JComponent toolbarComponent;//cpt 字体 等工具栏
private JPanel eastPane;//=largeToolbar+eastCenterPane
private UILargeToolbar largeToolbar;//预览
private JPanel eastCenterPane;//=combineUp + templateTabPane
private UIToolbar combineUp;//撤销重做 等工具栏
private JPanel templateTabPane;//新建模板 + 模板tab标签
private NewTemplatePane newWorkBookPane;//新建模板button
public static CenterRegionContainerPane getInstance() {
if (THIS == null) {
synchronized (CenterRegionContainerPane.class) {
if (THIS == null) {
THIS = new CenterRegionContainerPane();
}
}
}
return THIS;
}
public CenterRegionContainerPane() {
toolbarPane = new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
// dim.height = TOOLBAR_HEIGHT;
return dim;
}
};
toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout());
eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BorderLayout.WEST);
eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
combineUpTooBar();
eastCenterPane.add(combineUp, BorderLayout.NORTH);
templateTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
templateTabPane.add(newWorkBookPane = getToolBarMenuDock().getNewTemplatePane(), BorderLayout.WEST);
templateTabPane.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER);
eastCenterPane.add(templateTabPane, BorderLayout.CENTER);
eastPane.add(eastCenterPane, BorderLayout.CENTER);
toolbarPane.add(eastPane, BorderLayout.NORTH);
toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
this.setLayout(new BorderLayout());
this.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER);
this.add(toolbarPane, BorderLayout.NORTH);
}
private ToolBarMenuDock getToolBarMenuDock() {
return DesignerContext.getDesignerFrame().getToolBarMenuDock();
}
/**
* 创建上工具栏
*/
private void combineUpTooBar() {
combineUp = new UIToolbar(FlowLayout.LEFT);
combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR));
combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));
setUpUpToolBar(null);
}
/**
* 重置上工具栏
*/
private void resetCombineUpTooBar(JComponent[] toolbar4Form, ToolBarMenuDockPlus plus) {
combineUp.removeAll();
setUpUpToolBar(toolbar4Form);
plus.insertToCombineUpToolbar(combineUp);
}
/**
* 填充上工具栏的中的工具
*
* @param toolbar4Form 目标组件
*/
private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) {
UIButton[] fixButtons = getToolBarMenuDock().createUp();
for (UIButton fixButton : fixButtons) {
combineUp.add(fixButton);
}
if (!DesignModeContext.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) {
for (JComponent jComponent : toolbar4Form) {
combineUp.add(jComponent);
}
}
//添加检测按钮
addCheckButton();
}
//添加分享按钮
addShareButton();
//添加插件中的按钮
addExtraButtons();
}
private void addExtraButtons() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
UIButton[] extraButtons = jt.createExtraButtons();
for (UIButton extraButton : extraButtons) {
combineUp.add(extraButton);
}
if (extraButtons.length > 0) {
combineUp.addSeparator(new Dimension(2, 16));
}
}
private void addCheckButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] checkButtons = jt.createCheckButton();
for (UIButton checkButton : checkButtons) {
combineUp.add(checkButton);
}
}
private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] shareButtons = jt.createShareButton();
for (UIButton shareButton : shareButtons) {
combineUp.add(shareButton);
}
}
/**
* 检查
*
* @param flag 组件是否可见
* @param al 组件名称
*/
protected void checkCombineUp(boolean flag, ArrayList<String> al) {
//Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
// 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return
if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) {
return;
}
combineUp.checkComponentsByNames(flag, al);
}
}
/**
* 重置相关的工具条.
*
* @param plus 工具条中相关信息
*/
protected void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) {
resetCombineUpTooBar(ad.resetUpToolBar(plus), plus);
if (toolbarComponent != null) {
toolbarPane.remove(toolbarComponent);
}
// 颜色,字体那些按钮的工具栏
toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER);
if (plus.hasToolBarPane()) {
this.add(toolbarPane, BorderLayout.NORTH);
} else {
this.remove(toolbarPane);
}
resetByDesignMode();
}
private void resetByDesignMode() {
if (DesignModeContext.isDuchampMode()) {
eastPane.remove(largeToolbar);
eastCenterPane.remove(templateTabPane);
centerTemplateCardPane.refresh(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
} else {
eastPane.add(largeToolbar, BorderLayout.WEST);
eastCenterPane.add(templateTabPane, BorderLayout.CENTER);
}
}
JComponent getToolbarComponent() {
return this.toolbarComponent;
}
/**
* 判断是否在权限编辑状态若是在权限编辑状态则需要有虚线框和关闭突变
*/
protected void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing());
}
protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane;
}
protected void refreshUIToolBar() {
if (toolbarComponent instanceof UIToolbar) {
((UIToolbar ) toolbarComponent).refreshUIToolBar();
}
combineUp.refreshUIToolBar();
getToolBarMenuDock().updateEnable();
}
}

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

@ -4,9 +4,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
@ -22,24 +20,16 @@ import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.OemProcessor; import com.fr.design.fun.OemProcessor;
import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.os.impl.MacOsAddListenerAction; import com.fr.design.os.impl.MacOsAddListenerAction;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
@ -51,49 +41,32 @@ import com.fr.file.FILE;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.os.support.OSSupportCenter;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.start.OemHandler; import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jetbrains.annotations.Nullable;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLayeredPane; import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
@ -116,9 +89,12 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
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.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
@ -128,8 +104,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private static final long serialVersionUID = -8732559571067484460L; private static final long serialVersionUID = -8732559571067484460L;
private static final int LEFT_ALIGN_GAP = -5;
private static final int MENU_HEIGHT = 26; private static final int MENU_HEIGHT = 26;
private static final Integer SECOND_LAYER = 100; private static final Integer SECOND_LAYER = 100;
@ -140,22 +114,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private ToolBarMenuDock ad; private ToolBarMenuDock ad;
private DesktopCardPane centerTemplateCardPane;
private JPanel toolbarPane;
private JComponent toolbarComponent;
private JPanel menuPane;
private JMenuBar menuBar;
private JPanel eastCenterPane;
private UIToolbar combineUp;
private NewTemplatePane newWorkBookPane;
private Icon closeMode; private Icon closeMode;
private JLayeredPane layeredPane = this.getLayeredPane(); private JLayeredPane layeredPane = this.getLayeredPane();
@ -287,37 +245,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// the content pane // the content pane
basePane.setLayout(new BorderLayout()); basePane.setLayout(new BorderLayout());
toolbarPane = new JPanel() {
@Override basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER);
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
// dim.height = TOOLBAR_HEIGHT;
return dim;
}
};
toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
eastPane.add(ad.createLargeToolbar(), BorderLayout.WEST);
eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
combineUpTooBar();
eastCenterPane.add(combineUp, BorderLayout.NORTH);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(newWorkBookPane = ad.getNewTemplatePane(), BorderLayout.WEST);
panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER);
eastCenterPane.add(panel, BorderLayout.CENTER);
eastPane.add(eastCenterPane, BorderLayout.CENTER);
toolbarPane.add(eastPane, BorderLayout.NORTH);
toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER);
centerPane.add(toolbarPane, BorderLayout.NORTH);
basePane.add(centerPane, BorderLayout.CENTER);
laoyoutWestPane(); laoyoutWestPane();
basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST);
basePane.setBounds(0, 0, contentWidth, contentHeight); basePane.setBounds(0, 0, contentWidth, contentHeight);
@ -348,6 +277,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//刷新FixedPopupPane的位置 //刷新FixedPopupPane的位置
EastRegionContainerPane.getInstance().freshCurrentPopupPane(); EastRegionContainerPane.getInstance().freshCurrentPopupPane();
} }
@Override
public void componentMoved(ComponentEvent e) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshFormDesigner();
}
}
}); });
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false); this.setVisible(false);
@ -425,7 +362,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public DesktopCardPane getCenterTemplateCardPane() { public DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane; return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane();
}
public void refreshUIToolBar() {
CenterRegionContainerPane.getInstance().refreshUIToolBar();
} }
/** /**
@ -433,80 +374,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
protected void initMenuPane() { protected void initMenuPane() {
menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); basePane.add(NorthRegionContainerPane.getInstance(), BorderLayout.NORTH);
menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
menuPane.add(initNorthEastPane(ad), BorderLayout.EAST);
basePane.add(menuPane, BorderLayout.NORTH);
this.resetToolkitByPlus(null); this.resetToolkitByPlus(null);
} }
/**
* @param ad 菜单栏
* @return panel
*/
protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
//hugh: private修改为protected方便oem的时候修改右上的组件构成 return NorthRegionContainerPane.getInstance().initNorthEastPane(ad);
//顶部日志+登陆按钮
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) {
@Override
public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DesignerContext.getDesignerFrame() == null) {
return;
}
DesignerContext.getDesignerFrame().refresh();
DesignerContext.getDesignerFrame().repaint();
}
});
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign);
}
});
refreshNorthEastPane(northEastPane, ad);
return northEastPane;
}
private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) {
northEastPane.removeAll();
northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
northEastPane.add(LogMessageBar.getInstance());
TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING);
if (processor != null) {
final Component[] bbsLoginPane = {null};
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
bbsLoginPane[0] = ad.createBBSLoginPane();
}
}, SupportOSImpl.USERINFOPANE);
processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]);
}
northEastPane.add(ad.createAlphaFinePane());
if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) {
ad.createAlphaFinePane().setVisible(false);
}
northEastPane.add(ad.createNotificationCenterPane());
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
northEastPane.add(ad.createBBSLoginPane());
}
}, SupportOSImpl.USERINFOPANE);
} }
public void initTitleIcon() { public void initTitleIcon() {
@ -700,94 +573,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.closeMode = closeMode; this.closeMode = closeMode;
} }
/**
* 创建上工具栏
*/
private void combineUpTooBar() {
combineUp = new UIToolbar(FlowLayout.LEFT);
combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR));
combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));
setUpUpToolBar(null);
}
/**
* 重置上工具栏
*/
private void resetCombineUpTooBar(JComponent[] toolbar4Form) {
combineUp.removeAll();
setUpUpToolBar(toolbar4Form);
}
/**
* 填充上工具栏的中的工具
*
* @param toolbar4Form 目标组件
*/
private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) {
UIButton[] fixButtons = ad.createUp();
for (UIButton fixButton : fixButtons) {
combineUp.add(fixButton);
}
if (!DesignModeContext.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) {
for (JComponent jComponent : toolbar4Form) {
combineUp.add(jComponent);
}
}
//添加检测按钮
addCheckButton();
}
//添加分享按钮
addShareButton();
//添加插件中的按钮
addExtraButtons();
}
private void addExtraButtons() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
UIButton[] extraButtons = jt.createExtraButtons();
for (UIButton extraButton : extraButtons) {
combineUp.add(extraButton);
}
if (extraButtons.length > 0) {
combineUp.addSeparator(new Dimension(2, 16));
}
}
private void addCheckButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] checkButtons = jt.createCheckButton();
for (UIButton checkButton : checkButtons) {
combineUp.add(checkButton);
}
}
private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] shareButtons = jt.createShareButton();
for (UIButton shareButton : shareButtons) {
combineUp.add(shareButton);
}
}
/** /**
* 检查 * 检查
* *
@ -795,17 +580,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param al 组件名称 * @param al 组件名称
*/ */
public void checkCombineUp(boolean flag, ArrayList<String> al) { public void checkCombineUp(boolean flag, ArrayList<String> al) {
//Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 CenterRegionContainerPane.getInstance().checkCombineUp(flag, al);
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
// 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return
if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) {
return;
}
combineUp.checkComponentsByNames(flag, al);
}
} }
/** /**
* 刷新工具条. * 刷新工具条.
*/ */
@ -814,6 +592,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.ad.updateToolBarDef(); this.ad.updateToolBarDef();
} }
ToolBarMenuDock getToolBarMenuDock() {
return this.ad;
}
/** /**
* 重置相关的工具条. * 重置相关的工具条.
* *
@ -825,39 +607,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
plus = ToolBarMenuDock.NULLAVOID; plus = ToolBarMenuDock.NULLAVOID;
} }
DesignState designState = new DesignState(plus); NorthRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad);
MenuManager.getInstance().setMenus4Designer(designState);
if (menuBar == null) {
menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER);
} else {
ad.resetJMenuBar(menuBar, plus);
}
resetCombineUpTooBar(ad.resetUpToolBar(plus));
if (toolbarComponent != null) {
toolbarPane.remove(toolbarComponent);
}
// 颜色,字体那些按钮的工具栏 CenterRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad);
toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER);
this.checkToolbarMenuEnable(); this.checkToolbarMenuEnable();
this.validate(); this.validate();
layeredPane.repaint(); layeredPane.repaint();
} }
public void refreshUIToolBar() {
if (toolbarComponent instanceof UIToolbar) {
((UIToolbar ) toolbarComponent).refreshUIToolBar();
}
combineUp.refreshUIToolBar();
this.ad.updateEnable();
}
public JComponent getToolbarComponent() { public JComponent getToolbarComponent() {
return this.toolbarComponent; return CenterRegionContainerPane.getInstance().getToolbarComponent();
} }
/** /**
@ -865,7 +626,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void needToAddAuhtorityPaint() { public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); CenterRegionContainerPane.getInstance().needToAddAuhtorityPaint();
// 进入或退出权限编辑模式,通知插件 // 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
@ -983,7 +744,43 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public JTemplate<?, ?> getSelectedJTemplate() { public JTemplate<?, ?> getSelectedJTemplate() {
return this.centerTemplateCardPane.getSelectedJTemplate(); return getCenterTemplateCardPane().getSelectedJTemplate();
}
/**
* 保存当前编辑的模板
*/
public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) {
return;
}
if (editingTemplate.isSaved()) {// isSaved == true表示已经保存过,或者新建的一张模板
if (editingTemplate.getEditingFILE().exists()) {// 表示磁盘上的某一张已经保存过的模板,要添加到历史中
// HistoryTemplateListPane.getInstance().addHistory();
}
} else {
editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
}
} else {
if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
}
}
}
} }
/** /**
@ -1012,10 +809,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (jt == null || jt.getEditingFILE() == null) { if (jt == null || jt.getEditingFILE() == null) {
return; return;
} }
if (currentTemplateDeactivateFail()) {
return;
}
jt.addJTemplateActionListener(this); jt.addJTemplateActionListener(this);
jt.addTargetModifiedListener(this); jt.addTargetModifiedListener(this);
jt.addJTemplateActionListener(VcsHelper.getInstance()); jt.addJTemplateActionListener(VcsHelper.getInstance());
centerTemplateCardPane.showJTemplate(jt); getCenterTemplateCardPane().showJTemplate(jt);
refreshBaseContentPane(jt);
setTitle(); setTitle();
layeredPane.repaint(); layeredPane.repaint();
} }
@ -1033,11 +834,57 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (jt == null || jt.getEditingFILE() == null) { if (jt == null || jt.getEditingFILE() == null) {
return; return;
} }
centerTemplateCardPane.showJTemplate(jt); if (currentTemplateDeactivateFail()) {
return;
}
getCenterTemplateCardPane().showJTemplate(jt);
refreshBaseContentPane(jt);
setTitle(); setTitle();
layeredPane.repaint(); layeredPane.repaint();
} }
/**
* 当前模板 停用失败
*
* @return 是否停用失败
*/
private boolean currentTemplateDeactivateFail() {
JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return currentEditingTemplate != null && !currentEditingTemplate.deactivateTemplate();
}
/**
* 根据模板刷新 设计器整个界面
*
* @param jTemplate 当前模板
*/
public void refreshBaseContentPane(JTemplate jTemplate) {
JComponent north = jTemplate.north4DesignerFrame(),
center = jTemplate.center4DesignerFrame(),
west = jTemplate.west4DesignerFrame(),
east = jTemplate.east4DesignerFrame();
basePane.removeAll();
if (north != null) {
basePane.add(north, BorderLayout.NORTH);
}
if (center != null) {
basePane.add(center, BorderLayout.CENTER);
}
if (west != null) {
basePane.add(west, BorderLayout.WEST);
}
if (east != null) {
basePane.add(east, BorderLayout.EAST);
}
layeredPane.repaint();
layeredPane.revalidate();
}
/** /**
* 对象侦听 * 对象侦听
* *
@ -1109,16 +956,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
JOptionPane.WARNING_MESSAGE, JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon") UIManager.getIcon("OptionPane.errorIcon")
); );
if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate();
}
} catch (ChartNotFoundException e) {
FineJOptionPane.showMessageDialog(this,
Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
if (this.getSelectedJTemplate() == null) { if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate(); addAndActivateJTemplate();
} }

7
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -53,7 +53,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
// 判断是否切换设计器状态到禁止拷贝剪切 // 判断是否切换设计器状态到禁止拷贝剪切
if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT); DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT);
} else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) {
DesignModeContext.switchTo(DesignerMode.NORMAL); DesignModeContext.switchTo(DesignerMode.NORMAL);
} }
// 切换时 // 切换时
@ -61,6 +61,11 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
component.fireTabChange(); component.fireTabChange();
} }
DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt);
refresh(jt);
}
protected void refresh(final JTemplate<?, ?> jt) {
if (component != null) { if (component != null) {
layeredPane.remove(component); layeredPane.remove(component);
} }

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

@ -16,7 +16,6 @@ import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.reuse.ReuseGuideDialog; import com.fr.design.mainframe.reuse.ReuseGuideDialog;
import com.fr.design.mainframe.reuse.SnapChatKeys; import com.fr.design.mainframe.reuse.SnapChatKeys;
import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.menu.SnapChatUtil;
import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChat;
import com.fr.design.notification.SnapChatFactory; import com.fr.design.notification.SnapChatFactory;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
@ -114,7 +113,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
POLY_REPORT, // 聚合报表-报表块 POLY_REPORT, // 聚合报表-报表块
POLY_CHART(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 聚合报表-图表块 POLY_CHART(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 聚合报表-图表块
AUTHORITY_EDITION, // 权限编辑 AUTHORITY_EDITION, // 权限编辑
AUTHORITY_EDITION_DISABLED; // 权限编辑 AUTHORITY_EDITION_DISABLED, // 权限编辑
DUCHAMP_REPORT;
private String title; private String title;
@ -280,15 +280,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 单元格元素 // 单元格元素
PropertyItem cellElement = new PropertyItem(KEY_CELL_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Element"), PropertyItem cellElement = new PropertyItem(KEY_CELL_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Element"),
"cellelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, "cellelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT});
// 单元格属性 // 单元格属性
PropertyItem cellAttr = new PropertyItem(KEY_CELL_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), PropertyItem cellAttr = new PropertyItem(KEY_CELL_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"),
"cellattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, "cellattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT});
// 悬浮元素 // 悬浮元素
PropertyItem floatElement = new PropertyItem(KEY_FLOAT_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Float_Element"), PropertyItem floatElement = new PropertyItem(KEY_FLOAT_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Float_Element"),
"floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, "floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT});
// 控件设置 // 控件设置
PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"), PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"),
"widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY}, "widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY},
@ -296,11 +296,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 条件属性 // 条件属性
PropertyItem conditionAttr = new PropertyItem(KEY_CONDITION_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), PropertyItem conditionAttr = new PropertyItem(KEY_CONDITION_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"),
"conditionattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, "conditionattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT});
// 超级链接 // 超级链接
PropertyItem hyperlink = new PropertyItem(KEY_HYPERLINK, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Hyperlink"), PropertyItem hyperlink = new PropertyItem(KEY_HYPERLINK, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Hyperlink"),
"hyperlink", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, "hyperlink", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT});
// 组件库 // 组件库
widgetLibSnapChat = SnapChatFactory.createSnapChat(false, SnapChatKeys.COMPONENT); widgetLibSnapChat = SnapChatFactory.createSnapChat(false, SnapChatKeys.COMPONENT);
PropertyItem widgetLib = new PropertyItem( PropertyItem widgetLib = new PropertyItem(

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

@ -32,7 +32,6 @@ import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.TemplateResourceManager;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler; import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PreviewProvider;
@ -42,7 +41,6 @@ import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.chart.info.ChartInfoCollector;
@ -96,9 +94,6 @@ import javax.swing.SwingConstants;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager; import javax.swing.undo.UndoManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -107,6 +102,7 @@ import java.util.concurrent.Callable;
*/ */
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate { public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000; private static final int PREFIX_NUM = 3000;
protected FILE editingFILE = null; protected FILE editingFILE = null;
// alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存 // alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存
@ -127,7 +123,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected TemplateProcessInfo<T> processInfo; protected TemplateProcessInfo<T> processInfo;
private JComponent centerPane; private JComponent centerPane;
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter<T, ?> designModel; private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType; private PreviewProvider previewType;
/** /**
@ -156,7 +151,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
public JTemplate(T t, String defaultFileName) { public JTemplate(T t, String defaultFileName) {
this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); this(t, new MemFILE(JTemplateNameHelper.newTemplateNameByIndex(defaultFileName)), true);
} }
public JTemplate(T t, FILE file) { public JTemplate(T t, FILE file) {
@ -177,7 +172,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// 判断是否切换设计器状态到禁止拷贝剪切 // 判断是否切换设计器状态到禁止拷贝剪切
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);
} else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
} }
this.template = t; this.template = t;
@ -275,6 +270,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// do nothing // do nothing
} }
public void refreshFormDesigner() {
// do nothing
}
/** /**
* @deprecated move to cloud ops pluginleft only for compatible * @deprecated move to cloud ops pluginleft only for compatible
@ -706,8 +705,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
/** /**
* 添加图片到格子中 * 添加图片到格子中
*
* @return 返回图片URI
*/ */
public void setPictureElem(Elem elem, CellImage cellImage) { public void setPictureElem(Elem elem, CellImage cellImage) {
// 子类实现 // 子类实现
@ -927,7 +924,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false; return false;
} }
try { try {
this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); export();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);
@ -941,65 +938,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return true; return true;
} }
private static String newTemplateNameByIndex(String prefix) { protected boolean export() throws Exception {
// 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt" return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
// 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1
TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree();
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot();
String[] str = new String[gen.getChildCount()];
List<Integer> reportNum = new ArrayList<>();
for (int j = 0; j < gen.getChildCount(); j++) {
str[j] = gen.getChildAt(j).toString();
//返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了)
Integer index = getFileNameIndex(prefix, str[j]);
if (index != null) {
reportNum.add(index);
}
}
Collections.sort(reportNum);
int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1;
idx = idx + currentIndex;
currentIndex++;
return prefix + idx;
}
/**
* @return java.lang.Integer WorkBook11.cpt则返回11如果没有找到index返回null
* @Description 返回文件名中的index
* @param: prefix 前缀
* @param: fileName 文件名称全名
* @Author Henry.Wang
* @Date 2021/4/9 11:13
**/
private static Integer getFileNameIndex(String prefix, String fileName) {
char[] chars = new char[fileName.length()];
int i = 0;
for (; i < fileName.length(); i++) {
char c = fileName.charAt(i);
//匹配前缀
if (i < prefix.length()) {
if (c != prefix.charAt(i)) {
return null;
}
} else {
if (c == '.') {
break;
} else {
//匹配0~9
if (c < 48 || c > 57) {
return null;
}
chars[i - prefix.length()] = c;
}
}
}
String s = new String(chars).substring(0, i - prefix.length());
if (StringUtils.isBlank(s)) {
return null;
}
return Integer.valueOf(s);
} }
// /////////////////////////////toolbarMenuDock////////////////////////////////// // /////////////////////////////toolbarMenuDock//////////////////////////////////
@ -1254,6 +1195,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); DesignerContext.getDesignerFrame().addAndActivateJTemplate(this);
} }
/**
* 将要激活打开其他模板使当前模板灭活
* 默认 do nothing 返回true
*
* @return true成功停用当前模板
*/
public boolean deactivateTemplate() {
return true;
}
/** /**
* 返回当前支持的超链界面pane * 返回当前支持的超链界面pane
@ -1366,15 +1317,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/ */
public abstract Icon getIcon(); public abstract Icon getIcon();
/**
* 导出菜单项
*
* @return 菜单项
*/
@Override
public ShortCut[] shortcut4ExportMenu() {
return new ShortCut[0];
}
/** /**
* 复制JS代码 * 复制JS代码
@ -1506,6 +1448,46 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
/**
* 指定 设计器界面 NORTH组件
* 默认是 菜单区域
*
* @return NORTH组件
*/
public JComponent north4DesignerFrame() {
return NorthRegionContainerPane.getInstance();
}
/**
* 指定 设计器界面 CENTER组件
* 默认是 模板对应的工具栏区域+模板设计区域
*
* @return CENTER组件
*/
public JComponent center4DesignerFrame() {
return CenterRegionContainerPane.getInstance();
}
/**
* 指定 设计器界面 WEST组件
* 默认是 模板目录树+数据集编辑区域
*
* @return WEST组件
*/
public JComponent west4DesignerFrame() {
return WestRegionContainerPane.getInstance();
}
/**
* 指定 设计器界面 EAST组件
* 默认是 属性配置界面
*
* @return EAST组件
*/
public JComponent east4DesignerFrame() {
return EastRegionContainerPane.getInstance();
}
private CallbackSaveWorker save(boolean showLoc) { private CallbackSaveWorker save(boolean showLoc) {
FILE editingFILE = this.getEditingFILE(); FILE editingFILE = this.getEditingFILE();
// carl:editingFILE没有,当然不存了,虽然不会有这种情况 // carl:editingFILE没有,当然不存了,虽然不会有这种情况

83
designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java

@ -0,0 +1,83 @@
package com.fr.design.mainframe;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.stable.StringUtils;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/5/7
*/
public class JTemplateNameHelper {
private static final int PREFIX_NUM = 3000;
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
public static String newTemplateNameByIndex(String prefix) {
// 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt"
// 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1
TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree();
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot();
String[] str = new String[gen.getChildCount()];
List<Integer> reportNum = new ArrayList<>();
for (int j = 0; j < gen.getChildCount(); j++) {
str[j] = gen.getChildAt(j).toString();
//返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了)
Integer index = getFileNameIndex(prefix, str[j]);
if (index != null) {
reportNum.add(index);
}
}
Collections.sort(reportNum);
int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1;
idx = idx + currentIndex;
currentIndex++;
return prefix + idx;
}
/**
* @return java.lang.Integer WorkBook11.cpt则返回11如果没有找到index返回null
* @Description 返回文件名中的index
* @param: prefix 前缀
* @param: fileName 文件名称全名
* @Author Henry.Wang
* @Date 2021/4/9 11:13
**/
private static Integer getFileNameIndex(String prefix, String fileName) {
char[] chars = new char[fileName.length()];
int i = 0;
for (; i < fileName.length(); i++) {
char c = fileName.charAt(i);
//匹配前缀
if (i < prefix.length()) {
if (c != prefix.charAt(i)) {
return null;
}
} else {
if (c == '.') {
break;
} else {
//匹配0~9
if (c < 48 || c > 57) {
return null;
}
chars[i - prefix.length()] = c;
}
}
}
String s = new String(chars).substring(0, i - prefix.length());
if (StringUtils.isBlank(s)) {
return null;
}
return Integer.valueOf(s);
}
}

144
designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java

@ -0,0 +1,144 @@
package com.fr.design.mainframe;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuManager;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/4/6
*/
public class NorthRegionContainerPane extends JPanel {
private static volatile NorthRegionContainerPane THIS;
private JMenuBar menuBar;
public static NorthRegionContainerPane getInstance() {
if (THIS == null) {
synchronized (NorthRegionContainerPane.class) {
if (THIS == null) {
THIS = new NorthRegionContainerPane();
}
}
}
return THIS;
}
public NorthRegionContainerPane() {
ToolBarMenuDock ad = DesignerContext.getDesignerFrame().getToolBarMenuDock();
this.setLayout(new BorderLayout());
this.add(new UIMenuHighLight(), BorderLayout.SOUTH);
this.add(initNorthEastPane(ad), BorderLayout.EAST);
}
/**
* @param ad 菜单栏
* @return panel
*/
protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
//hugh: private修改为protected方便oem的时候修改右上的组件构成
//顶部日志+登陆按钮
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) {
@Override
public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DesignerContext.getDesignerFrame() == null) {
return;
}
DesignerContext.getDesignerFrame().refresh();
DesignerContext.getDesignerFrame().repaint();
}
});
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign);
}
});
refreshNorthEastPane(northEastPane, ad);
return northEastPane;
}
private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) {
northEastPane.removeAll();
northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
northEastPane.add(LogMessageBar.getInstance());
TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING);
if (processor != null) {
final Component[] bbsLoginPane = {null};
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
bbsLoginPane[0] = ad.createBBSLoginPane();
}
}, SupportOSImpl.USERINFOPANE);
processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]);
}
northEastPane.add(ad.createAlphaFinePane());
if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) {
ad.createAlphaFinePane().setVisible(false);
}
northEastPane.add(ad.createNotificationCenterPane());
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
northEastPane.add(ad.createBBSLoginPane());
}
}, SupportOSImpl.USERINFOPANE);
}
/**
* 重置相关的工具条.
*
* @param plus 工具条中相关信息
*/
void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) {
DesignState designState = new DesignState(plus);
MenuManager.getInstance().setMenus4Designer(designState);
if (menuBar == null) {
this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER);
} else {
ad.resetJMenuBar(menuBar, plus);
}
}
}

25
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -9,7 +9,19 @@ import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.community.*; import com.fr.design.actions.community.BBSAction;
import com.fr.design.actions.community.BugAction;
import com.fr.design.actions.community.BugNeedAction;
import com.fr.design.actions.community.CenterAction;
import com.fr.design.actions.community.FacebookFansAction;
import com.fr.design.actions.community.NeedAction;
import com.fr.design.actions.community.QuestionAction;
import com.fr.design.actions.community.SignAction;
import com.fr.design.actions.community.TechSolutionAction;
import com.fr.design.actions.community.TechSupportAction;
import com.fr.design.actions.community.TemplateStoreAction;
import com.fr.design.actions.community.VideoAction;
import com.fr.design.actions.community.WorkOrderCenterAction;
import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.CloseCurrentTemplateAction;
import com.fr.design.actions.file.ExitDesignerAction; import com.fr.design.actions.file.ExitDesignerAction;
import com.fr.design.actions.file.OpenRecentReportMenuDef; import com.fr.design.actions.file.OpenRecentReportMenuDef;
@ -64,7 +76,6 @@ import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.ObjectHolder; import com.fr.stable.bridge.ObjectHolder;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.os.support.OSSupportCenter;
import com.fr.start.OemHandler; import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -141,16 +152,6 @@ public abstract class ToolBarMenuDock {
return PANLE_HEIGNT; return PANLE_HEIGNT;
} }
/**
* 导出菜单的子菜单 目前用于图表设计器
*
* @return 子菜单
*/
@Override
public ShortCut[] shortcut4ExportMenu() {
return new ShortCut[0];
}
}; };
private static final int MENUBAR_HEIGHT = 22; private static final int MENUBAR_HEIGHT = 22;

21
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java

@ -1,11 +1,13 @@
package com.fr.design.mainframe.toolbar; package com.fr.design.mainframe.toolbar;
import javax.swing.*; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import javax.swing.JComponent;
import javax.swing.JPanel;
public interface ToolBarMenuDockPlus { public interface ToolBarMenuDockPlus {
/** /**
* 模板的工具 * 模板的工具
@ -54,10 +56,19 @@ public interface ToolBarMenuDockPlus {
int getToolBarHeight(); int getToolBarHeight();
/** /**
* 导出菜单的子菜单 目前用于图表设计器 * 是否含有工具栏 包含预览按钮 复制粘贴那一行 模板标签页那一行 字体颜色那一行
* *
* @return 子菜单 * @return 默认返回true
*/ */
ShortCut[] shortcut4ExportMenu(); default boolean hasToolBarPane() {
return true;
}
/**
* 复制粘贴那一行工具栏 插入 工具栏按钮
*/
default void insertToCombineUpToolbar(UIToolbar combineUp) {
}
} }

280
designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java

@ -3,266 +3,78 @@
*/ */
package com.fr.design.style.background.image; package com.fr.design.style.background.image;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.style.ChooseFileView; import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.filechooser.FileFilter; import com.fr.design.i18n.Toolkit;
import java.awt.Component; import com.fr.design.layout.FRGUIPaneFactory;
import java.awt.event.ActionEvent; import com.fr.design.mainframe.share.collect.ComponentCollector;
import java.awt.event.ActionListener; import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import javafx.stage.FileChooser;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File; import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
/** /**
* This class used to choose image files. * This class used to choose image files.
*/ */
public class ImageFileChooser extends ExpandFileChooser { public class ImageFileChooser {
public ImageFileChooser() {
super(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Compress"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open"));
ExampleFileFilter bothFilter = new ExampleFileFilter(
new String[]{"jpg", "gif", "png", "bmp"},
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"));
bothFilter.setExtensionListInDescription(true);
this.addChoosableFileFilter(bothFilter);
this.setAcceptAllFileFilterUsed(false);
// Create Custom FileView
ChooseFileView fileView = new ChooseFileView();
fileView.putIcon("jpg", BaseUtils.readIcon("/com/fr/base/images/dialog/file/jpgFile.gif"));
fileView.putIcon("gif", BaseUtils.readIcon("/com/fr/base/images/dialog/file/gifFile.gif"));
fileView.putIcon("png", BaseUtils.readIcon("/com/fr/base/images/dialog/file/pngFile.png"));
fileView.putIcon("bmp", BaseUtils.readIcon("/com/fr/base/images/dialog/file/bmpFile.gif"));
this.setFileView(fileView);
}
public int showDialog(Component parent, String approveButtonText) {
return super.showDialog(parent, approveButtonText);
}
@Override
public ActionListener checkAction() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DesignerEnvManager.getEnvManager().setImageCompress(isCheckSelected());
DesignerEnvManager.getEnvManager().saveXMLFile();
}
};
} JavaFxNativeFileChooser javaFxNativeFileChooser;
/**
* A convenience implementation of FileFilter that filters out
* all files except for those type extensions that it knows about.
* <p/>D:\finereport\develop\code\test\TestCase\WEB-INF\reportlets\TestCase\01903.cpt
* <p>
* Extensions are of the type ".foo", which is typically found on
* Windows and Unix boxes, but not on Macinthosh. Case is ignored.
* <p/>
* Example - create a new filter that filerts out all files
* but gif and jpg image files:
* <p/>
* JFileChooser chooser = new JFileChooser();
* ExampleFileFilter filter = new ExampleFileFilter(
* new String{"gif", "jpg"}, "JPEG & GIF Images")
* chooser.addChoosableFileFilter(filter);
* chooser.showOpenDialog(this);
*
* @author Jeff Dinkins
* @version 1.12 12/03/01
*/
class ExampleFileFilter extends FileFilter {
private Hashtable filters = null;
private String description = null;
private String fullDescription = null;
private boolean useExtensionsInDescription = true;
/**
* Creates a file filter. If no filters are added, then all
* files are accepted.
*
* @see #addExtension
*/
public ExampleFileFilter() {
this.filters = new Hashtable();
}
/**
* Creates a file filter that accepts files with the given extension.
* Example: new ExampleFileFilter("jpg");
*
* @see #addExtension
*/
public ExampleFileFilter(String extension) {
this(extension, null);
}
/**
* Creates a file filter that accepts the given file type.
* Example: new ExampleFileFilter("jpg", "JPEG Image Images");
* <p/>
* Note that the "." before the extension is not needed. If
* provided, it will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String extension, String description) {
this();
if (extension != null) addExtension(extension);
if (description != null) setDescription(description);
}
/** public ImageFileChooser() {
* Creates a file filter from the given string array. javaFxNativeFileChooser =
* Example: new ExampleFileFilter(String {"gif", "jpg"}); new JavaFxNativeFileChooser.Builder().
* <p/> fileSelectionMode(FileSelectionMode.FILE).
* Note that the "." before the extension is not needed adn title(Toolkit.i18nText("Fine-Design_Basic_Open")).
* will be ignored. filter(Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"), "*.jpg", "*.gif", "*.png", "*.bmp").
* build();
* @see #addExtension
*/
public ExampleFileFilter(String[] filters) {
this(filters, null);
} }
/**
* Creates a file filter from the given string array and description.
* Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
* <p/>
* Note that the "." before the extension is not needed and will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters, String description) {
this();
for (int i = 0; i < filters.length; i++) {
// add filters one by one
addExtension(filters[i]);
}
if (description != null) setDescription(description);
}
/** public int showOpenDialog(Component parent, String approveButtonText) {
* Return true if this file should be shown in the directory pane, return showOpenDialog(parent);
* false if it shouldn't.
* <p/>
* Files that begin with "." are ignored.
*
* @see #getExtension
*/
public boolean accept(File f) {
if (f != null) {
if (f.isDirectory()) {
return true;
}
String extension = getExtension(f);
if (extension != null && filters.get(getExtension(f)) != null) {
return true;
}
}
return false;
} }
/** public int showOpenDialog(Component parent) {
* Return the extension portion of the file's name . showImageCompressMoveTip();
* return javaFxNativeFileChooser.showDialog(parent);
* @see #getExtension
* @see javax.swing.filechooser.FileFilter#accept
*/
public String getExtension(File f) {
if (f != null) {
String filename = f.getName();
int i = filename.lastIndexOf('.');
if (i > 0 && i < filename.length() - 1) {
return filename.substring(i + 1).toLowerCase();
}
}
return null;
} }
/** public void setCurrentDirectory(File file) {
* Adds a filetype "dot" extension to filter against. javaFxNativeFileChooser.setCurrentDirectory(file);
* <p/>
* For example: the following code will create a filter that filters
* out all files except those that end in ".jpg" and ".tif":
* <p/>
* ExampleFileFilter filter = new ExampleFileFilter();
* filter.addExtension("jpg");
* filter.addExtension("tif");
* <p/>
* Note that the "." before the extension is not needed and will be ignored.
*/
public void addExtension(String extension) {
if (filters == null) {
filters = new Hashtable(5);
}
filters.put(extension.toLowerCase(), this);
fullDescription = null;
} }
public void setMultiSelectionEnabled(boolean multiple) {
/** if (multiple) {
* Returns the human readable description of this filter. For javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.MULTIPLE_FILE);
* example: "JPEG and GIF Image Files (*.jpg, *.gif)"
*
* @see javax.swing.filechooser.FileFilter#getDescription
*/
public String getDescription() {
if (fullDescription == null) {
if (description == null || isExtensionListInDescription()) {
fullDescription = description == null ? "(" : description + " (";
// build the description from the extension list
Enumeration extensions = filters.keys();
if (extensions != null) {
fullDescription += "." + extensions.nextElement();
while (extensions.hasMoreElements()) {
fullDescription += ", ." + extensions.nextElement();
}
}
fullDescription += ")";
} else { } else {
fullDescription = description; javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.FILE);
} }
} }
return fullDescription;
}
/** public File getSelectedFile() {
* Sets the human readable description of this filter. For return javaFxNativeFileChooser.getSelectedFile();
* example: filter.setDescription("Gif and JPG Images");
*/
public void setDescription(String description) {
this.description = description;
fullDescription = null;
} }
/** public boolean isCheckSelected() {
* Determines whether the extension list (.jpg, .gif, etc) should return DesignerEnvManager.getEnvManager().isImageCompress();
* show up in the human readable description.
* <p/>
* Only relevent if a description was provided in the constructor
* or using setDescription();
*/
public void setExtensionListInDescription(boolean b) {
useExtensionsInDescription = b;
fullDescription = null;
} }
/** private void showImageCompressMoveTip() {
* Returns whether the extension list (.jpg, .gif, etc) should if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) {
* show up in the human readable description. SwingUtilities.invokeLater(new Runnable() {
* <p/> @Override
* Only relevent if a description was provided in the constructor public void run() {
* or using setDescription(); DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip"));
*/ DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false);
public boolean isExtensionListInDescription() { }
return useExtensionsInDescription; });
} }
} }
} }

9
designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java

@ -11,7 +11,14 @@ import com.fr.stable.os.OperatingSystem;
public class ModernUIPaneFactory { public class ModernUIPaneFactory {
public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() { public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() {
if (OperatingSystem.isWindows()) { // 7.15的class不存在时 走老版本
boolean hasJxBrowserV7_15 = true;
try {
Class.forName("com.teamdev.jxbrowser.net.Scheme");
} catch (ClassNotFoundException e) {
hasJxBrowserV7_15 = false;
}
if (OperatingSystem.isWindows() && hasJxBrowserV7_15) {
return new NewModernUIPane.Builder<>(); return new NewModernUIPane.Builder<>();
} else { } else {
return new ModernUIPane.Builder<>(); return new ModernUIPane.Builder<>();

44
designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java

@ -16,15 +16,14 @@ import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.engine.EngineOptions; import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.RenderingMode; import com.teamdev.jxbrowser.engine.RenderingMode;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.net.Network; import com.teamdev.jxbrowser.net.Scheme;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import com.teamdev.jxbrowser.view.swing.BrowserView; import com.teamdev.jxbrowser.view.swing.BrowserView;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
@ -43,6 +42,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
private String namespace = "Pool"; private String namespace = "Pool";
private String variable = "data"; private String variable = "data";
private String expression = "update()"; private String expression = "update()";
private Scheme scheme;
private NxInterceptRequestCallback requestCallback;
private NewModernUIPane() { private NewModernUIPane() {
super(); super();
@ -96,7 +97,13 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
} }
private void initializeBrowser() { private void initializeBrowser() {
Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build()); EngineOptions options;
if (scheme != null && requestCallback != null) {
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build();
} else {
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build();
}
Engine engine = Engine.newInstance(options);
browser = engine.newBrowser(); browser = engine.newBrowser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
@ -124,8 +131,9 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public void redirect(String url, Map<String, String> map) { public void redirect(String url, Map<String, String> map) {
Network network = browser.engine().network(); if (requestCallback != null) {
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); requestCallback.setMap(map);
}
browser.navigation().loadUrl(url); browser.navigation().loadUrl(url);
} }
@ -169,8 +177,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withEMB(final String path) { public NewModernUIPane.Builder<T> withEMB(final String path) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("emb");
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, null)); pane.requestCallback = new NxComplexInterceptRequestCallback(null);
pane.browser.navigation().loadUrl("emb:" + path); pane.browser.navigation().loadUrl("emb:" + path);
return this; return this;
} }
@ -182,8 +190,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withURL(final String url) { public NewModernUIPane.Builder<T> withURL(final String url) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("file");
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.requestCallback = new NxComplexInterceptRequestCallback(null);
pane.browser.navigation().loadUrl(url); pane.browser.navigation().loadUrl(url);
return this; return this;
} }
@ -195,8 +203,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withURL(final String url, Map<String, String> map) { public NewModernUIPane.Builder<T> withURL(final String url, Map<String, String> map) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("file");
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); pane.requestCallback = new NxInterceptRequestCallback(map);
pane.browser.navigation().loadUrl(url); pane.browser.navigation().loadUrl(url);
return this; return this;
} }
@ -208,8 +216,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withComponent(AssembleComponent component) { public NewModernUIPane.Builder<T> withComponent(AssembleComponent component) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("emb");
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component)); pane.requestCallback = new NxComplexInterceptRequestCallback(component);
pane.browser.navigation().loadUrl("emb:dynamic"); pane.browser.navigation().loadUrl("emb:dynamic");
return this; return this;
} }
@ -221,8 +229,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withComponent(AssembleComponent component, Map<String, String> map) { public NewModernUIPane.Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("emb");
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component, map)); pane.requestCallback = new NxComplexInterceptRequestCallback(component, map);
pane.browser.navigation().loadUrl("emb:dynamic"); pane.browser.navigation().loadUrl("emb:dynamic");
return this; return this;
} }
@ -235,8 +243,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withHTML(String html) { public NewModernUIPane.Builder<T> withHTML(String html) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("html");
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.requestCallback = new NxInterceptRequestCallback();
pane.browser.mainFrame().ifPresent(frame -> { pane.browser.mainFrame().ifPresent(frame -> {
frame.loadHtml(html); frame.loadHtml(html);
}); });

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

@ -9,9 +9,6 @@ import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup; import com.fr.web.struct.PathGroup;
import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath; import com.fr.web.struct.category.StylePath;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -26,21 +23,20 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac
private AssembleComponent component; private AssembleComponent component;
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) { public NxComplexInterceptRequestCallback(AssembleComponent component) {
super(network);
this.component = component; this.component = component;
} }
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map<String, String> map) { public NxComplexInterceptRequestCallback(AssembleComponent component, Map<String, String> map) {
super(network, map); super(map);
this.component = component; this.component = component;
} }
@Override @Override
protected Response next(UrlRequest urlRequest, String path) { protected Response next(Params params, String path) {
if (path.startsWith("emb:dynamic")) { if (path.startsWith("emb:dynamic")) {
String text = htmlText(map); String text = htmlText(map);
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, "text/html", text.getBytes(StandardCharsets.UTF_8))); return Response.intercept(generateBasicUrlRequestJob(params, "text/html", text.getBytes(StandardCharsets.UTF_8)));
} else { } else {
int index = path.indexOf("="); int index = path.indexOf("=");
if (index > 0) { if (index > 0) {
@ -52,7 +48,7 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac
if (inputStream == null) { if (inputStream == null) {
return Response.proceed(); return Response.proceed();
} }
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); return Response.intercept(generateBasicUrlRequestJob(params, getMimeType(path), IOUtils.inputStream2Bytes(inputStream)));
} }
} }

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

@ -9,11 +9,10 @@ import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.net.URLCodec; import com.fr.third.org.apache.commons.codec.net.URLCodec;
import com.teamdev.jxbrowser.net.HttpHeader; import com.teamdev.jxbrowser.net.HttpHeader;
import com.teamdev.jxbrowser.net.HttpStatus; import com.teamdev.jxbrowser.net.HttpStatus;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.UrlRequest; import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.UrlRequestJob; import com.teamdev.jxbrowser.net.UrlRequestJob;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -29,17 +28,14 @@ import java.util.Optional;
* @version 10.0 * @version 10.0
* Created by richie on 2020/3/25 * Created by richie on 2020/3/25
*/ */
public class NxInterceptRequestCallback implements InterceptRequestCallback { public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
Network network;
Map<String, String> map; Map<String, String> map;
public NxInterceptRequestCallback(Network network) { public NxInterceptRequestCallback() {
this.network = network;
} }
public NxInterceptRequestCallback(Network network, Map<String, String> map) { public NxInterceptRequestCallback(Map<String, String> map) {
this.network = network;
this.map = map; this.map = map;
} }
@ -48,21 +44,21 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
UrlRequest urlRequest = params.urlRequest(); UrlRequest urlRequest = params.urlRequest();
String path = urlRequest.url(); String path = urlRequest.url();
if (path.startsWith("file:")) { if (path.startsWith("file:")) {
Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(urlRequest, path); Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(params, path);
if (optional.isPresent()) { if (optional.isPresent()) {
return InterceptRequestCallback.Response.intercept(optional.get()); return Response.intercept(optional.get());
} }
} else { } else {
return next(urlRequest, path); return next(params, path);
} }
return Response.proceed(); return Response.proceed();
} }
Response next(UrlRequest urlRequest, String path) { Response next(Params params, String path) {
return Response.proceed(); return Response.proceed();
} }
private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) { private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(Params params, String path) {
try { try {
String url = new URLCodec().decode(path); String url = new URLCodec().decode(path);
String filePath = TemplateUtils.renderParameter4Tpl(url, map); String filePath = TemplateUtils.renderParameter4Tpl(url, map);
@ -77,7 +73,7 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
} else { } else {
bytes = IOUtils.inputStream2Bytes(inputStream); bytes = IOUtils.inputStream2Bytes(inputStream);
} }
return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes)); return Optional.of(generateBasicUrlRequestJob(params, mimeType, bytes));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -88,12 +84,12 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType); return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType);
} }
UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) { UrlRequestJob generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) {
UrlRequestJob.Options options = UrlRequestJob.Options UrlRequestJob.Options options = UrlRequestJob.Options
.newBuilder(urlRequest.id(), HttpStatus.OK) .newBuilder(HttpStatus.OK)
.addHttpHeader(HttpHeader.of("Content-Type", mimeType)) .addHttpHeader(HttpHeader.of("Content-Type", mimeType))
.build(); .build();
UrlRequestJob urlRequestJob = network.newUrlRequestJob(options); UrlRequestJob urlRequestJob = params.newUrlRequestJob(options);
urlRequestJob.write(bytes); urlRequestJob.write(bytes);
urlRequestJob.complete(); urlRequestJob.complete();
return urlRequestJob; return urlRequestJob;
@ -145,4 +141,8 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
return "text/html"; return "text/html";
} }
} }
public void setMap(Map<String, String> map) {
this.map = map;
}
} }

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

@ -14,6 +14,9 @@ import com.fr.design.extra.exe.GetPluginPrefixExecutor;
import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; import com.fr.design.extra.exe.ReadUpdateOnlineExecutor;
import com.fr.design.extra.exe.SearchOnlineExecutor; import com.fr.design.extra.exe.SearchOnlineExecutor;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.BbsRegisterMark; import com.fr.design.locale.impl.BbsRegisterMark;
import com.fr.design.locale.impl.BbsResetMark; import com.fr.design.locale.impl.BbsResetMark;
@ -36,6 +39,7 @@ import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSArray; import com.teamdev.jxbrowser.chromium.JSArray;
import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject; import com.teamdev.jxbrowser.chromium.JSObject;
import javafx.stage.FileChooser;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
@ -95,7 +99,7 @@ public class UpmBridge {
@JSBridge @JSBridge
public void startDownload(final JSFunction callback) { public void startDownload(final JSFunction callback) {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
new SwingWorker<Void, Void>(){ new SwingWorker<Void, Void>() {
@Override @Override
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
UpmResourceLoader.INSTANCE.download(); UpmResourceLoader.INSTANCE.download();
@ -308,16 +312,13 @@ public class UpmBridge {
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() { RunnableFuture<String> future = new FutureTask<>(new Callable<String>() {
@Override @Override
public String call() { public String call() {
JFileChooser fileChooser = new JFileChooser(); FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileSelectionMode(FileSelectionMode.FILE).
filter(des, filter).
if (StringUtils.isNotEmpty(filter)) { build();
fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter))); int result = fileChooserProvider.showDialog(UpmFinder.getDialog());
}
int result = fileChooser.showOpenDialog(UpmFinder.getDialog());
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile().getAbsolutePath(); return fileChooserProvider.getSelectedFile().getAbsolutePath();
} }
return null; return null;
} }
@ -348,8 +349,8 @@ public class UpmBridge {
if (args instanceof String) { if (args instanceof String) {
filterList.add(GeneralUtils.objectToString(args)); filterList.add(GeneralUtils.objectToString(args));
} else if (args instanceof JSArray) { } else if (args instanceof JSArray) {
JSArray array = (JSArray)args; JSArray array = (JSArray) args;
for (int i = 0, len = array.length(); i < len; i ++) { for (int i = 0, len = array.length(); i < len; i++) {
filterList.add(array.get(i).getStringValue()); filterList.add(array.get(i).getStringValue());
} }
} }

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

@ -7,6 +7,7 @@ import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace; import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
@ -107,7 +108,7 @@ public class VersionCheckUtils {
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName)); CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName));
checkServiceDialog.setVisible(true); checkServiceDialog.setVisible(true);
} }
}); },DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.check.dialog"));
notificationDialog.setVisible(true); notificationDialog.setVisible(true);
} }

16
designer-base/src/main/java/com/fr/design/web/CustomIconPane.java

@ -10,6 +10,8 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextarea.DescriptionTextArea;
@ -28,6 +30,7 @@ import com.fr.stable.ListMap;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade; import com.fr.transaction.WorkerFacade;
import javafx.stage.FileChooser;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
@ -108,7 +111,7 @@ public class CustomIconPane extends BasicPane {
} }
protected String createDescriptionText(){ protected String createDescriptionText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1");
} }
@ -447,13 +450,12 @@ public class CustomIconPane extends BasicPane {
} }
private void onBrowseButtonClicked() { private void onBrowseButtonClicked() {
JFileChooser jf = new JFileChooser();
// carl:不知道是否只要png格式,反正导出时全部都转成png了 // carl:不知道是否只要png格式,反正导出时全部都转成png了
FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("Icon Image File", "jpg", "jpeg", "png", "gif"); FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
jf.setFileFilter(fileFilter); filter("Icon Image File", "*.jpg", "*.jpeg", "*.png", "*.gif").
build();
if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) { if (JFileChooser.APPROVE_OPTION == fileChooserProvider.showDialog(DesignerContext.getDesignerFrame())) {
String path = jf.getSelectedFile().getAbsolutePath(); String path = fileChooserProvider.getSelectedFile().getAbsolutePath();
// 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储 // 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储
Image image = BaseUtils.readImage(path); Image image = BaseUtils.readImage(path);
iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH); iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH);

30
designer-base/src/main/java/com/fr/env/HelpLink.java vendored

@ -0,0 +1,30 @@
package com.fr.env;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.locale.InterProviderFactory;
import com.fr.stable.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 错误提示中的跳转链接管理
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/9
*/
public class HelpLink {
public static String getLink(String solution) {
Map<String, String> map = new HashMap<>();
LocaleMark<String> linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class);
String link = linkMark.getValue();
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_NetWork_Connection_Error_Solution"), link);
return map.get(solution);
}
}

36
designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java vendored

@ -0,0 +1,36 @@
package com.fr.env;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/9
*/
public class RemoteDesignLocaleMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
private static final String REMOTE_DESIGN_CN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.zh_CN", "https://help.fanruan.com/finereport/doc-view-3925.html");
private static final String REMOTE_DESIGN_EN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.en_US", "https://help.fanruan.com/finereport-en/doc-view-3862.html");
public RemoteDesignLocaleMark() {
map.put(Locale.CHINA, REMOTE_DESIGN_CN);
map.put(Locale.KOREA, REMOTE_DESIGN_EN);
map.put(Locale.JAPAN, REMOTE_DESIGN_EN);
map.put(Locale.US, REMOTE_DESIGN_EN);
map.put(Locale.TAIWAN, REMOTE_DESIGN_CN);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? REMOTE_DESIGN_CN : result;
}
}

56
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -4,13 +4,14 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPassWordField; import com.fr.design.gui.ipasswordfield.UIPassWordField;
import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength;
@ -19,17 +20,13 @@ import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder; import com.fr.design.scrollruler.ModLineBorder;
import com.fr.license.exception.RegistEditionException; import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Strings; import com.fr.third.guava.base.Strings;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -62,9 +59,7 @@ import java.io.File;
import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.FILL;
import static com.fr.design.layout.TableLayout.PREFERRED; import static com.fr.design.layout.TableLayout.PREFERRED;
import static com.fr.env.TestConnectionResult.AUTH_FAILED;
import static com.fr.third.guava.base.Optional.fromNullable; import static com.fr.third.guava.base.Optional.fromNullable;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/** /**
* @author yaohwu * @author yaohwu
@ -569,11 +564,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
fileChooserButton.addActionListener(new ActionListener() { fileChooserButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser(); FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().fileSelectionMode(FileSelectionMode.FILE).build();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
int saveValue = fileChooser.showOpenDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
if (saveValue == JFileChooser.APPROVE_OPTION) { if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile(); File selectedFile = fileChooserProvider.getSelectedFile();
certPathInput.setText(selectedFile.getAbsolutePath()); certPathInput.setText(selectedFile.getAbsolutePath());
} }
} }
@ -585,42 +579,24 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection(); final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<TestConnectionResult, Void> worker = new SwingWorker<TestConnectionResult, Void>() { final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override @Override
protected TestConnectionResult doInBackground() throws Exception { protected Boolean doInBackground() throws Exception {
try { return WorkContext.getConnector().testConnection(connection);
return TestConnectionResult.parse(WorkContext.getConnector().testConnection(connection), connection);
} catch (WorkspaceAuthException ignored) {
return AUTH_FAILED;
} catch (RegistEditionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw e;
} catch (WorkspaceCheckException e) {
return TestConnectionResult.parseByException(e);
}
} }
@Override @Override
protected void done() { protected void done() {
okButton.setEnabled(true); okButton.setEnabled(true);
try { try {
TestConnectionResult result = get(); if (get()) {
if (result.isVerifyResult()) { message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
dialog.dispose(); uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord")); }
FineJOptionPane.showMessageDialog(RemoteEnvPane.this,
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
message.setText(result.getText());
uiLabel.setIcon(result.getIcon());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); dialog.dispose();
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv);
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} }
dialogDownPane.remove(cancelButton); dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate(); dialogDownPane.revalidate();

16
designer-base/src/main/java/com/fr/env/handler/Handler.java vendored

@ -0,0 +1,16 @@
package com.fr.env.handler;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public interface Handler<T, R> {
/**
* @param t
* @return 是否需要继续处理
*/
R handle(T t);
}

28
designer-base/src/main/java/com/fr/env/handler/RefWrapper.java vendored

@ -0,0 +1,28 @@
package com.fr.env.handler;
/**
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/11
*/
public class RefWrapper {
private final Throwable throwable;
private final String link;
public RefWrapper(Throwable throwable, String link) {
this.throwable = throwable;
this.link = link;
}
public Throwable getThrowable() {
return throwable;
}
public String getLink() {
return link;
}
}

90
designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java vendored

@ -0,0 +1,90 @@
package com.fr.env.handler;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.i18n.Toolkit;
import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.handler.impl.CancelHandler;
import com.fr.env.handler.impl.CommonHandler;
import com.fr.env.handler.impl.ExecutionHandler;
import com.fr.env.handler.impl.UnexpectedHandler;
import com.fr.log.FineLoggerFactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class RemoteDesignExceptionHandler {
private static final RemoteDesignExceptionHandler INSTANCE = new RemoteDesignExceptionHandler();
public static RemoteDesignExceptionHandler getInstance() {
return INSTANCE;
}
private final List<Handler<RefWrapper, ResultWrapper>> testList = new ArrayList<>();
private final List<Handler<RefWrapper, ResultWrapper>> switchList = new ArrayList<>();
private RemoteDesignExceptionHandler() {
// 要保证顺序
testList.add(new CancelHandler());
testList.add(new ExecutionHandler());
testList.add(new UnexpectedHandler());
testList.add(new CommonHandler(false));
switchList.add(new CancelHandler());
switchList.add(new ExecutionHandler());
switchList.add(new UnexpectedHandler());
switchList.add(new CommonHandler(true));
}
public void handle(Throwable e, List<Handler<RefWrapper, ResultWrapper>> list, DesignerWorkspaceInfo workspaceInfo) {
Throwable throwable = e;
ResultWrapper wrapper;
String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH;
for (Handler<RefWrapper, ResultWrapper> handler : list) {
wrapper = handler.handle(new RefWrapper(throwable, link));
throwable = wrapper.getThrowable();
if (!wrapper.isNext()) {
break;
}
}
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
}
public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
return;
}
handle(e, switchList, workspaceInfo);
}
public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return;
}
handle(e, testList, workspaceInfo);
}
public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
handle(e, testList, workspaceInfo);
}
}

30
designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java vendored

@ -0,0 +1,30 @@
package com.fr.env.handler;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class ResultWrapper {
private final boolean next;
private final Throwable throwable;
public ResultWrapper(Throwable throwable) {
this(true, throwable);
}
public ResultWrapper(boolean next, Throwable e) {
this.next = next;
this.throwable = e;
}
public boolean isNext() {
return next;
}
public Throwable getThrowable() {
return throwable;
}
}

22
designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java vendored

@ -0,0 +1,22 @@
package com.fr.env.handler.impl;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import java.util.concurrent.CancellationException;
/**
* 取消测试连接时的处理器
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class CancelHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
return new ResultWrapper(!(e instanceof CancellationException), e);
}
}

52
designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java vendored

@ -0,0 +1,52 @@
package com.fr.env.handler.impl;
import com.fr.base.exception.ExceptionDescriptor;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.UIDetailErrorLinkDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.HelpLink;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import com.fr.stable.StringUtils;
import javax.swing.SwingUtilities;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class CommonHandler implements Handler<RefWrapper, ResultWrapper> {
private final boolean onSwitch;
public CommonHandler(boolean onSwitch) {
this.onSwitch = onSwitch;
}
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (e instanceof ExceptionDescriptor) {
ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String link = HelpLink.getLink(exceptionDescriptor.solution());
UIDetailErrorLinkDialog detailErrorLinkDialog = UIDetailErrorLinkDialog.newBuilder().
setWindow(onSwitch ? DesignerContext.getDesignerFrame() : EnvChangeEntrance.getInstance().getDialog()).
setErrorCode(exceptionDescriptor.errorCode()).
setReason(exceptionDescriptor.reason()).
setSolution(exceptionDescriptor.solution()).
setDetailReason(exceptionDescriptor.detailReason()).
setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")).
setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link).
setThrowable(e).build();
detailErrorLinkDialog.setVisible(true);
}
});
}
return new ResultWrapper(e);
}
}

23
designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java vendored

@ -0,0 +1,23 @@
package com.fr.env.handler.impl;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import java.util.concurrent.ExecutionException;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class ExecutionHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (e instanceof ExecutionException) {
return new ResultWrapper(e.getCause());
}
return new ResultWrapper(e);
}
}

26
designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java vendored

@ -0,0 +1,26 @@
package com.fr.env.handler.impl;
import com.fr.base.exception.ExceptionDescriptor;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import com.fr.workspace.engine.convert.ExceptionConverter;
/**
* 出现预料之外的情况异常处理器
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class UnexpectedHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (!(e instanceof ExceptionDescriptor)) {
return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ;
}
return new ResultWrapper(e);
}
}

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

@ -4,3 +4,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280
com.fr.design.report.ReportColumnsPane=800*600 com.fr.design.report.ReportColumnsPane=800*600
com.fr.env.RemoteEnvPane.dialog=458*132 com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=490*95

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

@ -3,3 +3,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280
com.fr.env.RemoteEnvPane.dialog=458*132 com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=430*95

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

@ -3,3 +3,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280
com.fr.env.RemoteEnvPane.dialog=458*132 com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=450*95

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

@ -4,3 +4,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280
com.fr.env.RemoteEnvPane.dialog=308*132 com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.design.version.check.dialog=230*95

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

@ -3,3 +3,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280
com.fr.env.RemoteEnvPane.dialog=308*132 com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.design.version.check.dialog=230*95

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

21
designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java vendored

@ -4,7 +4,10 @@ import com.fr.invoke.Reflect;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper; import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.connect.WorkspaceConnector;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert; import org.junit.Assert;
@ -18,15 +21,31 @@ import java.io.ByteArrayOutputStream;
*/ */
public class RemoteDesignerWorkspaceInfoTest extends TestCase { public class RemoteDesignerWorkspaceInfoTest extends TestCase {
public void testCheckValid() { public void testCheckValid() throws Exception {
RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true));
WorkspaceConnector connector = WorkContext.getConnector();
WorkspaceConnector workspaceConnector = new WorkspaceConnector() {
@Override
public boolean testConnection(WorkspaceConnectionInfo connection) throws Exception {
return false;
}
@Override
public WorkspaceClient connect(WorkspaceConnectionInfo connection) throws Exception {
return null;
}
};
WorkContext.setConnector(workspaceConnector);
Assert.assertFalse(workspaceInfo0.checkValid()); Assert.assertFalse(workspaceInfo0.checkValid());
Assert.assertFalse(workspaceInfo1.checkValid()); Assert.assertFalse(workspaceInfo1.checkValid());
Assert.assertFalse(workspaceInfo2.checkValid()); Assert.assertFalse(workspaceInfo2.checkValid());
Assert.assertFalse(workspaceInfo3.checkValid()); Assert.assertFalse(workspaceInfo3.checkValid());
WorkContext.setConnector(connector);
} }
public void testReadXml() { public void testReadXml() {

23
designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java

@ -0,0 +1,23 @@
package com.fr.design.mainframe;
import junit.framework.TestCase;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/5/8
*/
public class JTemplateNameHelperTest extends TestCase {
public void testNewTemplateNameByIndex() {
String name = JTemplateNameHelper.newTemplateNameByIndex("TEST");
assertEquals("TEST1", name);
String name1 = JTemplateNameHelper.newTemplateNameByIndex("TEST");
assertEquals("TEST2", name1);
}
}

207
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -8,7 +8,6 @@ import com.fr.chart.fun.ChartTypeProvider;
import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.attr.ChartProvider;
import com.fr.common.annotations.Compatible; import com.fr.common.annotations.Compatible;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.fun.ChartTypeUIProvider;
import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.chart.gui.ChartWidgetOption;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
@ -46,7 +45,6 @@ import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.PiePlot4VanChart;
import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.area.VanChartAreaPlot;
import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.plugin.chart.box.VanChartBoxPlot;
@ -75,7 +73,6 @@ import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.solution.closeable.CloseableContainedMap; import com.fr.plugin.solution.closeable.CloseableContainedMap;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider;
import com.fr.van.chart.area.AreaIndependentVanChartInterface; import com.fr.van.chart.area.AreaIndependentVanChartInterface;
@ -100,17 +97,7 @@ import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface;
import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface;
import javax.swing.Icon; import javax.swing.Icon;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.awt.event.ActionListener;
import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY;
import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY;
import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY;
/** /**
* Created by eason on 14/12/29. * Created by eason on 14/12/29.
@ -120,10 +107,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager(); private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager();
private static LinkedHashMap<String, CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap>> chartTypeInterfaces = private static CloseableContainedMap<String, ChartTypeUIProvider, HashMap> chartTypeUIs = new CloseableContainedMap<>(HashMap.class);
new LinkedHashMap<String, CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap>>();
private static Map<String, String> idAndPriorityMap = new HashMap<String, String>();
public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME"; public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME";
@ -186,127 +170,69 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static void readVanChart() { private static void readVanChart() {
addChartTypeInterface(VAN_CHART_PRIORITY, PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); addChartTypeInterface(PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); addChartTypeInterface(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); addChartTypeInterface(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); addChartTypeInterface(VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); addChartTypeInterface(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); addChartTypeInterface(VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); addChartTypeInterface(VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); addChartTypeInterface(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); addChartTypeInterface(VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); addChartTypeInterface(VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); addChartTypeInterface(VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); addChartTypeInterface(VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); addChartTypeInterface(VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); addChartTypeInterface(VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); addChartTypeInterface(VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); addChartTypeInterface(VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); addChartTypeInterface(VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); addChartTypeInterface(VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); addChartTypeInterface(VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI());
addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); addChartTypeInterface(VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface());
} }
private static void readDefault() { private static void readDefault() {
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); addChartTypeInterface(ChartConstants.COLUMN_CHART, new ColumnChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineChartTypeUI()); addChartTypeInterface(ChartConstants.LINE_CHART, new LineChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarChartTypeUI()); addChartTypeInterface(ChartConstants.BAR_CHART, new BarChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieChartTypeUI()); addChartTypeInterface(ChartConstants.PIE_CHART, new PieChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaChartTypeUI()); addChartTypeInterface(ChartConstants.AREA_CHART, new AreaChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); addChartTypeInterface(ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); addChartTypeInterface(ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarChartTypeUI()); addChartTypeInterface(ChartConstants.RADAR_CHART, new RadarChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockChartTypeUI()); addChartTypeInterface(ChartConstants.STOCK_CHART, new StockChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterChartTypeUI()); addChartTypeInterface(ChartConstants.METER_CHART, new MeterChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeChartTypeUI()); addChartTypeInterface(ChartConstants.RANGE_CHART, new RangeChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); addChartTypeInterface(ChartConstants.CUSTOM_CHART, new CustomChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttChartTypeUI()); addChartTypeInterface(ChartConstants.GANTT_CHART, new GanttChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutChartTypeUI()); addChartTypeInterface(ChartConstants.DONUT_CHART, new DonutChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapChartTypeUI()); addChartTypeInterface(ChartConstants.MAP_CHART, new MapChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); addChartTypeInterface(ChartConstants.GIS_CHAER, new GisMapChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); addChartTypeInterface(ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI());
} }
private static void addChartTypeInterface(String priority, String plotID, ChartTypeUIProvider provider) { private static void addChartTypeInterface(String id, ChartTypeUIProvider provider) {
if (chartTypeInterfaces != null) { if (chartTypeUIs != null) {
if (!chartTypeInterfaces.containsKey(priority)) { chartTypeUIs.put(id, provider);
//新建一个具体图表列表
CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap> chartUIList
= new CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap>(LinkedHashMap.class);
chartUIList.put(plotID, provider);
chartTypeInterfaces.put(priority, chartUIList);
} else {
Map<String, ChartTypeUIProvider> chartUIList = chartTypeInterfaces.get(priority);
if (!chartUIList.containsKey(plotID)) {
chartUIList.put(plotID, provider);
}
}
idAndPriorityMap.put(plotID, priority);
} }
} }
private ChartTypeUIProvider getChartTypeInterface(String plotID) { private ChartTypeUIProvider getChartTypeInterface(String id) {
if (idAndPriorityMap.containsKey(plotID)) { if (chartTypeUIs.containsKey(id)) {
String priority = idAndPriorityMap.get(plotID); return chartTypeUIs.get(id);
if (chartTypeInterfaces.containsKey(priority)) {
return chartTypeInterfaces.get(priority).get(plotID);
}
} }
return null; return null;
} }
/** public AbstractChartTypePane getPlotTypePane(String id) {
* 把所有的pane加到list里 if (chartTypeUIs.containsKey(id)) {
* return chartTypeUIs.get(id).getPlotTypePane();
* @param paneList pane容器
*/
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends ChartProvider>> paneList,
Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) {
List<Integer> priorityList = getPriorityInOrder();
for (Integer aPriorityList : priorityList) {
String priority = String.valueOf(aPriorityList);
addPlotTypePaneList(priority, paneList, allChartTypePane, autoButtonListener);
}
}
public void addPlotTypePaneList(String priority, List<FurtherBasicBeanPane<? extends ChartProvider>> paneList,
Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) {
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) {
Map<String, ChartTypeUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Iterator<Map.Entry<String, ChartTypeUIProvider>> iterator = chartUIList.entrySet().iterator();
while (iterator.hasNext()) {
try {
Map.Entry<String, ChartTypeUIProvider> entry = iterator.next();
String plotID = entry.getKey();
AbstractChartTypePane pane = entry.getValue().getPlotTypePane();
if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) {
continue;
}
pane.reLayout(plotID);
pane.registerButtonListener(autoButtonListener);
paneList.add(pane);
if (allChartTypePane.get(priority) == null) {
allChartTypePane.put(priority, new LinkedHashMap<String, FurtherBasicBeanPane<? extends ChartProvider>>());
}
allChartTypePane.get(priority).put(plotID, pane);
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
} }
return null;
} }
@Compatible @Compatible
@ -314,23 +240,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
return getName(plotID); return getName(plotID);
} }
private List<Integer> getPriorityInOrder() {
List<Integer> priorityList = new ArrayList<Integer>();
if (chartTypeInterfaces != null) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String priority = (String) entry.getKey();
priorityList.add(Integer.valueOf(priority));
}
}
return ChartTypeManager.orderInPriority(priorityList);
}
public String getIconPath(String plotID) { public String getIconPath(String plotID) {
if (chartTypeInterfaces != null) { if (chartTypeUIs != null) {
ChartTypeUIProvider provider = getChartTypeInterface(plotID); ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) { if (provider != null) {
return provider.getIconPath(); return provider.getIconPath();
@ -341,7 +253,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public String[] getDemoImagePath(String chartID) { public String[] getDemoImagePath(String chartID) {
if (chartTypeInterfaces != null) { if (chartTypeUIs != null) {
ChartTypeUIProvider provider = getChartTypeInterface(chartID); ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) { if (provider != null) {
String[] result = null; String[] result = null;
@ -397,7 +309,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
} }
public String[] getSubName(String chartID) { public String[] getSubName(String chartID) {
if (chartTypeInterfaces != null) { if (chartTypeUIs != null) {
ChartTypeUIProvider provider = getChartTypeInterface(chartID); ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) { if (provider != null) {
String[] subNames = null; String[] subNames = null;
@ -430,7 +342,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
} }
public String getName(String chartID) { public String getName(String chartID) {
if (chartTypeInterfaces != null) { if (chartTypeUIs != null) {
ChartTypeUIProvider provider = getChartTypeInterface(chartID); ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) { if (provider != null) {
String name = null; String name = null;
@ -575,9 +487,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
id = injection.getAttribute("plotID"); id = injection.getAttribute("plotID");
} }
String priority = injection.getAttribute("priority", DEFAULT_PRIORITY);
ChartTypeUIProvider instance = (ChartTypeUIProvider) injection.getObject(); ChartTypeUIProvider instance = (ChartTypeUIProvider) injection.getObject();
addChartTypeInterface(priority, id, instance); addChartTypeInterface(id, instance);
} }
} }
@ -586,22 +497,18 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public void demount(PluginSingleInjection injection) { public void demount(PluginSingleInjection injection) {
if (isChartTypeUIProvider(injection)) { if (isChartTypeUIProvider(injection)) {
String priority = injection.getAttribute("priority", DEFAULT_PRIORITY);
String id = injection.getAttribute("chartID"); String id = injection.getAttribute("chartID");
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
id = injection.getAttribute("plotID"); id = injection.getAttribute("plotID");
} }
removeChartTypeInterface(priority, id); removeChartTypeInterface(id);
} }
} }
private void removeChartTypeInterface(String priority, String plotID) { private void removeChartTypeInterface(String id) {
if (chartTypeInterfaces != null) { if (chartTypeUIs != null) {
if (chartTypeInterfaces.containsKey(priority)) { chartTypeUIs.remove(id);
Map<String, ChartTypeUIProvider> chartUIList = chartTypeInterfaces.get(priority);
chartUIList.remove(plotID);
}
} }
} }

32
designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java

@ -90,7 +90,9 @@ public interface ChartTypeUIProvider extends Level {
//todo:把下面这些接口删除 //todo:把下面这些接口删除
@Deprecated @Deprecated
boolean needChartChangePane(); default boolean needChartChangePane() {
return false;
}
/** /**
* 数据集数据源的界面 * 数据集数据源的界面
@ -98,7 +100,9 @@ public interface ChartTypeUIProvider extends Level {
* @return 数据集数据源的界面 * @return 数据集数据源的界面
*/ */
@Deprecated @Deprecated
AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent); default AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
return null;
}
/** /**
@ -107,7 +111,9 @@ public interface ChartTypeUIProvider extends Level {
* @return 单元格数据源的界面 * @return 单元格数据源的界面
*/ */
@Deprecated @Deprecated
AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent); default AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
return null;
}
/** /**
* 条件属性界面 * 条件属性界面
@ -115,7 +121,9 @@ public interface ChartTypeUIProvider extends Level {
* @return 条件属性界面 * @return 条件属性界面
*/ */
@Deprecated @Deprecated
ConditionAttributesPane getPlotConditionPane(Plot plot); default ConditionAttributesPane getPlotConditionPane(Plot plot) {
return null;
}
/** /**
* 系列界面 * 系列界面
@ -123,7 +131,9 @@ public interface ChartTypeUIProvider extends Level {
* @return 系列界面 * @return 系列界面
*/ */
@Deprecated @Deprecated
BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot); default BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot) {
return null;
}
/** /**
* 是否使用默认的界面为了避免界面来回切换 * 是否使用默认的界面为了避免界面来回切换
@ -131,12 +141,18 @@ public interface ChartTypeUIProvider extends Level {
* @return 是否使用默认的界面 * @return 是否使用默认的界面
*/ */
@Deprecated @Deprecated
boolean isUseDefaultPane(); default boolean isUseDefaultPane() {
return false;
}
@Deprecated @Deprecated
ChartEditPane getChartEditPane(String plotID); default ChartEditPane getChartEditPane(String plotID) {
return new ChartEditPane();
}
@Deprecated @Deprecated
ChartsConfigPane getChartConfigPane(String plotID); default ChartsConfigPane getChartConfigPane(String plotID) {
return null;
}
} }

1
designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java

@ -6,6 +6,7 @@ import com.fr.common.annotations.Compatible;
* Created by shine on 2019/09/05. * Created by shine on 2019/09/05.
*/ */
@Compatible @Compatible
@Deprecated
public interface IndependentChartUIProvider extends ChartTypeUIProvider { public interface IndependentChartUIProvider extends ChartTypeUIProvider {
} }

59
designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java

@ -1,19 +1,11 @@
package com.fr.design.chart.fun.impl; package com.fr.design.chart.fun.impl;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.fun.ChartTypeUIProvider;
import com.fr.design.chartx.impl.AbstractDataPane; import com.fr.design.chartx.impl.AbstractDataPane;
import com.fr.design.chartx.impl.AbstractOtherPane;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartsConfigPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
@ -24,13 +16,15 @@ import com.fr.stable.fun.mark.API;
public abstract class AbstractChartTypeUI extends AbstractProvider implements ChartTypeUIProvider { public abstract class AbstractChartTypeUI extends AbstractProvider implements ChartTypeUIProvider {
@Override @Override
public abstract AbstractChartTypePane getPlotTypePane(); public AbstractChartTypePane getPlotTypePane() {
return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new DefaultChartTypePane();
}
@Override @Override
public abstract AbstractDataPane getChartDataPane(AttributeChangeListener listener); public abstract AbstractDataPane getChartDataPane(AttributeChangeListener listener);
@Override @Override
public abstract AbstractOtherPane[] getAttrPaneArray(AttributeChangeListener listener); public abstract AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener);
@Override @Override
public String[] getSubName() { public String[] getSubName() {
@ -46,45 +40,4 @@ public abstract class AbstractChartTypeUI extends AbstractProvider implements Ch
public String mark4Provider() { public String mark4Provider() {
return getClass().getName(); return getClass().getName();
} }
@Override
public boolean needChartChangePane() {
return false;
}
@Override
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
return null;
}
@Override
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
return null;
}
@Override
public boolean isUseDefaultPane() {
return false;
}
@Override
public ChartEditPane getChartEditPane(String plotID) {
return new ChartEditPane();
}
@Override
public ConditionAttributesPane getPlotConditionPane(Plot plot) {
return null;
}
@Override
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot) {
return null;
}
@Override
public ChartsConfigPane getChartConfigPane(String plotID) {
return null;
}
} }

1
designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java

@ -17,6 +17,7 @@ import com.fr.stable.StableUtils;
/** /**
* Created by Mitisky on 16/3/7. * Created by Mitisky on 16/3/7.
*/ */
@Deprecated
public abstract class AbstractIndependentChartUIWithAPILevel implements ChartTypeUIProvider { public abstract class AbstractIndependentChartUIWithAPILevel implements ChartTypeUIProvider {
//这个不能改,是做兼容用的 //这个不能改,是做兼容用的
//2016.10.14-11.24号的8.0jar因为改了这个为3,不会提示5.26号之前的插件更新 //2016.10.14-11.24号的8.0jar因为改了这个为3,不会提示5.26号之前的插件更新

38
designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java

@ -0,0 +1,38 @@
package com.fr.design.chart.fun.impl;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
/**
* @author shine
* @version 10.0
* Created by shine on 2020/7/8
*/
public class DefaultChartTypePane<T extends ChartProvider> extends AbstractChartTypePane<T> {
@Override
protected String[] getTypeIconPath() {
return ChartTypeInterfaceManager.getInstance().getDemoImagePath(this.getPlotID());
}
@Override
protected String[] getTypeTipName() {
return ChartTypeInterfaceManager.getInstance().getSubName(this.getPlotID());
}
public ChartProvider getDefaultChart() {
return ChartTypeManager.getInstance().getChartTypes(this.getPlotID())[0];
}
public String title4PopupWindow() {
return ChartTypeInterfaceManager.getInstance().getName(this.getPlotID());
}
@Override
public void populateBean(T ob) {
}
}

15
designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java

@ -0,0 +1,15 @@
package com.fr.design.chart.fun.impl;
import com.fr.design.ChartTypeInterfaceManager;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/6/25
*/
public class InvisibleChartTypePane extends DefaultChartTypePane {
@Override
public String title4PopupWindow() {
return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE;
}
}

36
designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

@ -9,6 +9,8 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -40,7 +42,7 @@ import java.awt.event.ItemListener;
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-10-15 下午03:38:15 * @version 创建时间2012-10-15 下午03:38:15
*/ */
public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAttrEditPane{ // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAttrEditPane { // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替)
private FilterComboBox<String> areaString;// 区域字段 private FilterComboBox<String> areaString;// 区域字段
private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮 private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮
@ -52,7 +54,7 @@ public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAt
initComp(); initComp();
} }
public MapCustomPane(boolean isNeedDataSource){ public MapCustomPane(boolean isNeedDataSource) {
this.isNeedDataSource = isNeedDataSource; this.isNeedDataSource = isNeedDataSource;
initComp(); initComp();
} }
@ -83,13 +85,13 @@ public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAt
loadMap.addActionListener(selectPictureActionListener); loadMap.addActionListener(selectPictureActionListener);
if(isNeedDataSource){ if (isNeedDataSource) {
UILabel label =new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT) ; UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT);
tableDataNameBox = new DatabaseTableDataPane(label) { tableDataNameBox = new DatabaseTableDataPane(label) {
protected void userEvent() { protected void userEvent() {
refreshAreaNameBox(); refreshAreaNameBox();
} }
}; };
tableDataNameBox.setPreferredSize(new Dimension(200, 20)); tableDataNameBox.setPreferredSize(new Dimension(200, 20));
northPane.add(tableDataNameBox); northPane.add(tableDataNameBox);
@ -109,14 +111,12 @@ refreshAreaNameBox();
private ActionListener selectPictureActionListener = new ActionListener() { private ActionListener selectPictureActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
JFileChooser svgFileChooser = new JFileChooser(); FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
svgFileChooser.addChoosableFileFilter(new SVGFileFilter()); filter(".svg, .svgz", "*.svg", "*.svgz").
if (StringUtils.isNotBlank(lastSelectPath)) { currentDirectory(lastSelectPath).build();
svgFileChooser.setSelectedFile(new File(lastSelectPath)); int returnVal = fileChooserProvider.showDialog(DesignerContext.getDesignerFrame());
}
int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (returnVal != JFileChooser.CANCEL_OPTION) { if (returnVal != JFileChooser.CANCEL_OPTION) {
File selectedFile = svgFileChooser.getSelectedFile(); File selectedFile = fileChooserProvider.getSelectedFile();
try { try {
lastSelectPath = selectedFile.getCanonicalPath(); lastSelectPath = selectedFile.getCanonicalPath();
} catch (Exception ex) { } catch (Exception ex) {
@ -153,13 +153,13 @@ refreshAreaNameBox();
FineLoggerFactory.getLogger().error(ee.getMessage(), ee); FineLoggerFactory.getLogger().error(ee.getMessage(), ee);
} }
if(embeddedTableData == null){ if (embeddedTableData == null) {
return colValues; return colValues;
} }
int columnIndex = getColumnIndex(embeddedTableData, colName); int columnIndex = getColumnIndex(embeddedTableData, colName);
if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){ if (columnIndex == DataModel.COLUMN_NAME_NOT_FOUND) {
return colValues; return colValues;
} }
@ -192,7 +192,7 @@ refreshAreaNameBox();
} }
private void refreshAreaNameBox() {// 刷新区域名称列表 private void refreshAreaNameBox() {// 刷新区域名称列表
if(!isNeedDataSource){ if (!isNeedDataSource) {
return; return;
} }
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
@ -204,7 +204,7 @@ refreshAreaNameBox();
Object oldSelected = areaString.getSelectedItem(); Object oldSelected = areaString.getSelectedItem();
areaString.removeAllItems(); areaString.removeAllItems();
for(String item : columnNameList) { for (String item : columnNameList) {
areaString.addItem(item); areaString.addItem(item);
} }
areaString.getModel().setSelectedItem(oldSelected); areaString.getModel().setSelectedItem(oldSelected);
@ -215,7 +215,7 @@ refreshAreaNameBox();
* @param typeName 类别名 * @param typeName 类别名
* @param mapName 地图名 * @param mapName 地图名
*/ */
public void setTypeNameAndMapName(String typeName, String mapName){ public void setTypeNameAndMapName(String typeName, String mapName) {
imageShowPane.setTypeNameAndMapName(typeName, mapName); imageShowPane.setTypeNameAndMapName(typeName, mapName);
} }

25
designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java

@ -2,7 +2,7 @@ package com.fr.design.chartx.data.map;
import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection; import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.chartx.fields.diff.LineMapDataSetFieldsPane; import com.fr.design.chartx.fields.diff.MapDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -24,15 +24,15 @@ public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWith
private UIComboBox toLng_tab1; private UIComboBox toLng_tab1;
private UIComboBox toLat_tab1; private UIComboBox toLat_tab1;
private LineMapDataSetFieldsPane lineMapDataSetFieldsPane; private MapDataSetFieldsPane mapDataSetFieldsPane;
public LineMapAreaLngLatPaneWithComboBox(LineMapDataSetFieldsPane lineMapDataSetFieldsPane) { public LineMapAreaLngLatPaneWithComboBox(MapDataSetFieldsPane mapDataSetFieldsPane) {
this.lineMapDataSetFieldsPane = lineMapDataSetFieldsPane; this.mapDataSetFieldsPane = mapDataSetFieldsPane;
initComponents(); initComponents();
} }
protected void initComponents() { protected void initComponents() {
if (lineMapDataSetFieldsPane == null) { if (mapDataSetFieldsPane == null) {
return; return;
} }
super.initComponents(); super.initComponents();
@ -48,7 +48,7 @@ public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWith
return createPane( return createPane(
new String[]{Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), new String[]{Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"),
Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")}, Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")},
lineMapDataSetFieldsPane.createAreaPanel(fromArea_tab0), lineMapDataSetFieldsPane.createAreaPanel(toArea_tab0) mapDataSetFieldsPane.createAreaPanel(fromArea_tab0), mapDataSetFieldsPane.createAreaPanel(toArea_tab0)
); );
} }
@ -64,18 +64,19 @@ public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWith
} }
return createPane( return createPane(
new String[]{ new String[]{
Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"),
Toolkit.i18nText("Fine-Design_Chart_Start_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Start_Longitude"),
Toolkit.i18nText("Fine-Design_Chart_Start_Latitude"), Toolkit.i18nText("Fine-Design_Chart_Start_Latitude"),
Toolkit.i18nText("Fine-Design_Chart_End_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"),
Toolkit.i18nText("Fine-Design_Chart_End_Longitude"), Toolkit.i18nText("Fine-Design_Chart_End_Longitude"),
Toolkit.i18nText("Fine-Design_Chart_End_Latitude")}, Toolkit.i18nText("Fine-Design_Chart_End_Latitude"),
lineMapDataSetFieldsPane.createAreaPanel(fromArea_tab1), Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")
},
fromLng_tab1, fromLng_tab1,
fromLat_tab1, fromLat_tab1,
lineMapDataSetFieldsPane.createAreaPanel(toArea_tab1), fromArea_tab1,
toLng_tab1, toLng_tab1,
toLat_tab1); toLat_tab1,
toArea_tab1);
} }
protected void populateTab0(LineMapColumnFieldCollection fieldCollection) { protected void populateTab0(LineMapColumnFieldCollection fieldCollection) {

16
designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java

@ -2,7 +2,7 @@ package com.fr.design.chartx.data.map;
import com.fr.chartx.data.field.diff.PointMapColumnFieldCollection; import com.fr.chartx.data.field.diff.PointMapColumnFieldCollection;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import com.fr.design.chartx.fields.diff.PointMapDataSetFieldsPane; import com.fr.design.chartx.fields.diff.MapDataSetFieldsPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -20,15 +20,15 @@ public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWi
private UIComboBox lng_tab1; private UIComboBox lng_tab1;
private UIComboBox lat_tab1; private UIComboBox lat_tab1;
private PointMapDataSetFieldsPane pointMapDataSetFieldsPane; private MapDataSetFieldsPane mapDataSetFieldsPane;
public PointMapAreaLngLatPaneWithComboBox(PointMapDataSetFieldsPane pointMapDataSetFieldsPane) { public PointMapAreaLngLatPaneWithComboBox(MapDataSetFieldsPane pointMapDataSetFieldsPane) {
this.pointMapDataSetFieldsPane = pointMapDataSetFieldsPane; this.mapDataSetFieldsPane = pointMapDataSetFieldsPane;
initComponents(); initComponents();
} }
protected void initComponents() { protected void initComponents() {
if (pointMapDataSetFieldsPane == null) { if (mapDataSetFieldsPane == null) {
return; return;
} }
super.initComponents(); super.initComponents();
@ -41,7 +41,7 @@ public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWi
} }
return createPane( return createPane(
new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name")}, new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name")},
pointMapDataSetFieldsPane.createAreaPanel(area_tab0) mapDataSetFieldsPane.createAreaPanel(area_tab0)
); );
} }
@ -53,8 +53,8 @@ public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWi
lat_tab1 = new UIComboBox(); lat_tab1 = new UIComboBox();
} }
return createPane( return createPane(
new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Latitude")}, new String[]{Toolkit.i18nText("Fine-Design_Chart_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Latitude"), Toolkit.i18nText("Fine-Design_Chart_Area_Name")},
pointMapDataSetFieldsPane.createAreaPanel(area_tab1), lng_tab1, lat_tab1 lng_tab1, lat_tab1, area_tab1
); );
} }

2
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java

@ -21,7 +21,7 @@ public abstract class AbstractCellDataFieldsWithSeriesValuePane<T extends Column
seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane(); seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane();
if (normalCenter != null) { if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout(0,6)); JPanel panel = new JPanel(new BorderLayout(0, 6));
panel.add(normalCenter, BorderLayout.NORTH); panel.add(normalCenter, BorderLayout.NORTH);
panel.add(seriesValueFieldsPane, BorderLayout.CENTER); panel.add(seriesValueFieldsPane, BorderLayout.CENTER);
return panel; return panel;

15
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java

@ -5,8 +5,8 @@ import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane;
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.List;
/** /**
* Created by shine on 2019/5/16. * Created by shine on 2019/5/16.
@ -20,10 +20,10 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane<T extends ColumnF
@Override @Override
protected JPanel createCenterPane() { protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane(); JPanel normalCenter = super.createCenterPane();
seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane(); getSeriesValueFieldComboBoxPane();
if (normalCenter != null) { if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout(0,6)); JPanel panel = new JPanel(new BorderLayout(0, 6));
panel.add(normalCenter, BorderLayout.NORTH); panel.add(normalCenter, BorderLayout.NORTH);
panel.add(seriesValueFieldComboBoxPane, BorderLayout.CENTER); panel.add(seriesValueFieldComboBoxPane, BorderLayout.CENTER);
return panel; return panel;
@ -34,7 +34,14 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane<T extends ColumnF
public SeriesValueFieldComboBoxPane getSeriesValueFieldComboBoxPane() { public SeriesValueFieldComboBoxPane getSeriesValueFieldComboBoxPane() {
if (seriesValueFieldComboBoxPane == null) { if (seriesValueFieldComboBoxPane == null) {
seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane(); seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane() {
protected boolean seriesComboBoxHasNone() {
return true;
}
};
} }
return seriesValueFieldComboBoxPane; return seriesValueFieldComboBoxPane;
} }

13
designer-chart/src/main/java/com/fr/design/chartx/impl/AbstractDataPane.java

@ -45,12 +45,16 @@ public abstract class AbstractDataPane extends ChartDataPane {
ChartDataDefinitionProvider dataDefinition = chart.getChartDataDefinition(); ChartDataDefinitionProvider dataDefinition = chart.getChartDataDefinition();
singleDataPane.populateBean((AbstractDataDefinition) dataDefinition); populate(dataDefinition);
this.initAllListeners(); this.initAllListeners();
this.validate(); this.validate();
} }
protected void populate(ChartDataDefinitionProvider dataDefinition) {
singleDataPane.populateBean((AbstractDataDefinition) dataDefinition);
}
@Override @Override
public void update(ChartCollection collection) { public void update(ChartCollection collection) {
@ -62,6 +66,11 @@ public abstract class AbstractDataPane extends ChartDataPane {
return; return;
} }
chart.setChartDataDefinition(singleDataPane.updateBean()); chart.setChartDataDefinition(update());
} }
protected ChartDataDefinitionProvider update() {
return singleDataPane.updateBean();
}
} }

5
designer-chart/src/main/java/com/fr/design/chartx/impl/AbstractOtherPane.java

@ -3,6 +3,7 @@ package com.fr.design.chartx.impl;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.impl.AbstractChartWithData; import com.fr.chart.impl.AbstractChartWithData;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
/** /**
* Created by shine on 2019/09/04. * Created by shine on 2019/09/04.
@ -13,6 +14,10 @@ public abstract class AbstractOtherPane<T extends AbstractChartWithData> extends
protected abstract void update(T chart); protected abstract void update(T chart);
public String title4PopupWindow() {
return PaneTitleConstants.CHART_OTHER_TITLE;
}
@Override @Override
public void populate(ChartCollection collection) { public void populate(ChartCollection collection) {
if (collection == null) { if (collection == null) {

48
designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java

@ -8,16 +8,23 @@ import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.chart.chartglyph.Marker; import com.fr.chart.chartglyph.Marker;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.ConfigHelper;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.plugin.chart.ConfigHelper;
import javax.swing.DefaultComboBoxModel;
import javax.swing.*; import javax.swing.JLabel;
import java.awt.*; import javax.swing.JList;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
/** /**
* Combobox for selecting marker. * Combobox for selecting marker.
@ -53,32 +60,39 @@ public class MarkerComboBox extends UIComboBox {
* CellRenderer. * CellRenderer.
*/ */
class MarkerCellRenderer extends UIComboBoxRenderer { class MarkerCellRenderer extends UIComboBoxRenderer {
private Marker marker = null;
private boolean isSelected = false;
public Component getListCellRendererComponent(JList list, public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) { Object value, int index, boolean isSelected, boolean cellHasFocus) {
this.marker = (Marker) value; this.marker = (Marker) value;
this.isSelected = isSelected; this.isSelected = isSelected;
return this; String text = null;
if (marker != null) {
boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
if (isAutoMarker || isNullMarker) {
text = isNullMarker
? Toolkit.i18nText("Fine-Design_Report_None")
: Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
}
}
JLabel comp = (JLabel) super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus);
return comp;
} }
public void paint(Graphics g) { public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize(); Dimension d = getSize();
g2d.setColor(Color.black);
g2d.setFont(FRContext.getDefaultValues().getFRFont());
if (marker != null) { if (marker != null) {
boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
if (isAutoMarker || isNullMarker) { if (isAutoMarker || isNullMarker) {
String text = isNullMarker super.paint(g);
?Toolkit.i18nText("Fine-Design_Report_None")
:Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
paintTextMarker(g2d, d, text);
} else { } else {
g2d.setColor(Color.black);
if (marker.getBackground() == null) { if (marker.getBackground() == null) {
marker.setBackground(ColorBackground.getInstance(Color.black)); marker.setBackground(ColorBackground.getInstance(Color.black));
} }
@ -100,8 +114,6 @@ public class MarkerComboBox extends UIComboBox {
return getPreferredSize(); return getPreferredSize();
} }
private Marker marker = null;
private boolean isSelected = false;
private void paintTextMarker(Graphics2D g2d, Dimension d, String text) { private void paintTextMarker(Graphics2D g2d, Dimension d, String text) {
g2d.setColor(Color.black); g2d.setColor(Color.black);

7
designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java

@ -16,6 +16,7 @@ import com.fr.design.gui.chart.ChartEditPaneProvider;
import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.frpane.UITitlePanel;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.AssistUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
@ -35,6 +36,9 @@ public class ChartPropertyPane extends BaseChartPropertyPane {
protected ChartEditPane chartEditPane; protected ChartEditPane chartEditPane;
//ID一样的话 不用新建chartEditPane
private String currentID;
private ChartPropertyPane() { private ChartPropertyPane() {
initComponent(); initComponent();
} }
@ -46,10 +50,13 @@ public class ChartPropertyPane extends BaseChartPropertyPane {
@Override @Override
public void updateChartEditPane(String plotID) { public void updateChartEditPane(String plotID) {
if (!AssistUtils.equals(currentID, plotID)) {
chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID); chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID);
chartEditPane.setContainer(container); chartEditPane.setContainer(container);
currentID = plotID;
resetChartEditPane(); resetChartEditPane();
} }
}
@Override @Override
public ChartEditPaneProvider getChartEditPane() { public ChartEditPaneProvider getChartEditPane() {

112
designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java

@ -1,112 +0,0 @@
package com.fr.design.mainframe;
import com.fr.chart.base.MapSvgAttr;
import com.fr.chart.base.MapSvgXMLHelper;
import com.fr.chart.chartglyph.MapShapeValue;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.series.PlotSeries.AbstrctMapAttrEditPane;
import com.fr.design.chart.series.PlotSeries.MapCustomPane;
import com.fr.design.chart.series.PlotSeries.MapDefiAreaNamePane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/2
* Time: 下午7:17
*/
public class MapEditPane extends BasicBeanPane<MapSvgAttr>{
private UITabbedPane tabbedPane;
private MapCustomPane areaPane ;
// private MapCustomPane pointPane;
private MapDefiAreaNamePane namedPane;
private String currentMapName;
private AbstrctMapAttrEditPane editingPane;
private ChangeListener tabbedChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
switch ( tabbedPane.getSelectedIndex()){
case 1:
namedPane.populateMapAttr(editingPane.updateCurrentAttr());
editingPane = namedPane;
break;
default:
areaPane.populateMapAttr(editingPane.updateCurrentAttr());
editingPane = areaPane;
}
}
} ;
public MapEditPane(){
initTabbedPane();
this.setLayout(new BorderLayout());
this.add(tabbedPane,BorderLayout.CENTER);
}
private void initTabbedPane(){
tabbedPane = new UITabbedPane();
areaPane = new MapCustomPane(false);
// pointPane = new MapCustomPane(false);
namedPane= new MapDefiAreaNamePane(false);
areaPane.setImageSelectType(MapShapeValue.AREA);
// pointPane.setImageSelectType(MapShapeValue.POINT);
tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Image_Area"),areaPane);
// tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("FR-Chart-Map_ImagePoint"),pointPane);
tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Corresponding_Fields"),namedPane);
editingPane = areaPane;
}
@Override
protected String title4PopupWindow() {
return null;
}
@Override
public void populateBean(MapSvgAttr ob) {
if(!StringUtils.isEmpty(ob.getName()) && !MapSvgXMLHelper.getInstance().containsMapName(ob.getName())){
MapSvgAttr mapSvgAttr = new MapSvgAttr();
mapSvgAttr.setFilePath(MapSvgXMLHelper.customMapPath()+ CoreConstants.SEPARATOR+ob.getName()+".svg");
MapSvgXMLHelper.getInstance().addNewSvgMaps(ob.getName(), mapSvgAttr);
}
currentMapName = ob.getName();
if(editingPane == null){
editingPane = areaPane;
}
editingPane.populateMapAttr(ob);
tabbedPane.addChangeListener(tabbedChangeListener);
}
public String getCurrentMapName(){
return currentMapName;
}
public void setCurrentMapName(String currentMapName){
this.currentMapName = currentMapName;
}
@Override
public MapSvgAttr updateBean() {
MapSvgAttr currentAttr = editingPane.updateCurrentAttr();
currentMapName =currentAttr != null ? currentAttr.getName() : currentMapName;
MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(currentMapName);
if(attr != null ){
MapSvgXMLHelper.getInstance().removeNewMapAttr(currentMapName);
MapSvgXMLHelper.getInstance().pushMapAttr(currentMapName,currentAttr);
return currentAttr;
}else{
return MapSvgXMLHelper.getInstance().getNewMapAttr(currentMapName);
}
}
}

51
designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java

@ -9,6 +9,7 @@ import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.chart.ChartEditPaneActionListener;
import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.chart.ChartEditPaneProvider;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.ibutton.UIHeadGroup;
@ -19,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartOtherPane; import com.fr.design.mainframe.chart.gui.ChartOtherPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.ChartTypePane; import com.fr.design.mainframe.chart.gui.ChartTypePane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -28,11 +30,11 @@ import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JPanel; 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.BorderLayout;
import java.awt.CardLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.awt.BorderLayout;
import java.awt.CardLayout;
public class ChartEditPane extends BasicPane implements AttributeChange, Prepare4DataSourceChange, ChartEditPaneProvider { public class ChartEditPane extends BasicPane implements AttributeChange, Prepare4DataSourceChange, ChartEditPaneProvider {
@ -102,6 +104,33 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare
this.add(center, BorderLayout.CENTER); this.add(center, BorderLayout.CENTER);
} }
/**
* 增加面板Listener
*/
public void addChartEditPaneActionListener(ChartEditPaneActionListener l) {
this.listenerList.add(ChartEditPaneActionListener.class, l);
}
/**
* 移除面板Listener
*/
public void removeChartEditPaneActionListener(ChartEditPaneActionListener l) {
this.listenerList.remove(ChartEditPaneActionListener.class, l);
}
private void fireAttributeChange(ChartCollection chartCollection) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 1; i >= 0; i -= 1) {
if (listeners[i] == ChartEditPaneActionListener.class) {
((ChartEditPaneActionListener) listeners[i + 1]).attributeChange(chartCollection);
}
}
}
AttributeChangeListener listener = new AttributeChangeListener() { AttributeChangeListener listener = new AttributeChangeListener() {
@Override @Override
public void attributeChange() { public void attributeChange() {
@ -131,6 +160,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare
} }
fire(); fire();
fireAttributeChange(collection);
} }
} }
}; };
@ -147,13 +177,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare
*/ */
public void reLayout(ChartProvider currentChart) { public void reLayout(ChartProvider currentChart) {
if (currentChart != null) { if (currentChart != null) {
int chartIndex = getSelectedChartIndex(currentChart);
this.removeAll(); this.removeAll();
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
paneList = new ArrayList<AbstractChartAttrPane>(); paneList = new ArrayList<AbstractChartAttrPane>();
addTypePane();
String chartID = currentChart.getID(); String chartID = currentChart.getID();
addTypePane(currentChart);
boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
if (isDefault) { if (isDefault) {
@ -187,9 +217,18 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare
return chartDataPane; return chartDataPane;
} }
protected void addTypePane() { protected void addTypePane(ChartProvider chart) {
if (visibleTypePane(chart)) {
paneList.add(typePane); paneList.add(typePane);
} }
}
private boolean visibleTypePane(ChartProvider chart) {
AbstractChartTypePane pane = ChartTypeInterfaceManager.getInstance().getPlotTypePane(chart.getID());
return pane != null
&& !ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE.equals(pane.title4PopupWindow())
&& pane.visible(chart);
}
protected void setSelectedTab() { protected void setSelectedTab() {
} }

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

Loading…
Cancel
Save