Browse Source

Pull request #1806: 无jira任务, release/10.0 合 feature/10.0

Merge in DESIGN/design from release/10.0 to feature/10.0

* commit '0b28fbee04131a98ba0ba1b5cd1c44daf3a24506': (163 commits)
  REPORT-35253 切换远程到本地设计器的问题
  REPORT-34780 && CHART-14441
  CHART-14624  调整面积图系列面板不透明的enable属性的check
  REPORT-35381 && REPORT-35379
  CHART-14541 轴标题增加缩进
  REPORT-34020 【国际化】非简中设计器-界面右侧面板选择超链接或悬浮元素后下拉框溢出
  CHART-14120 英文设计器地图数据面板截断
  REPORT-33236
  REPORT-31546 公式面板的说明切换偶尔会失效
  REPORT-34351 ""改为StringUtils.EMPTY
  REPORT-33500 日志面板清除日志后同时清除设计器右上角日志提示信息
  REPORT-35016【组件生成】目前生成的组件,从组件库拖入模板中会变大 [场景] 从组件库拖入时,不会保持原有的大小。 [解决方案] 将原来的大小,在创建时一并初始化
  CHART-14346
  CHART-14346 悬浮窗图表组合图不允许选择单元格数据源
  REPORT-34954 富文本上标下标不应该可以同时设置
  REPORT-34954 富文本上标下标可以同时设置
  CHART-14180  优化代码
  CHART-14346 && CHART-14180  悬浮图表配置组合图不能选择单元格数据源 && 轴标题隐藏优化
  REPORT-34385 修改联网搜索的enable条件
  REPORT-34351 修正FineJOptionPane组件showInputDialog()方法点击弹出框的取消键后的行为;在组件重命名后将与自己的原来的名字进行对比的情况去除
  ...
research/11.0
ju.ju 5 years ago
parent
commit
6bef9131d1
  1. 6
      .gitignore
  2. 10
      build.gradle
  3. 54
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 37
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  5. 7
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  6. 2
      designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java
  7. 12
      designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java
  8. 14
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  9. 32
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  10. 31
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  11. 5
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  12. 29
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  13. 18
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java
  14. 12
      designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java
  15. 6
      designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java
  16. 31
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  17. 3
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  18. 20
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java
  19. 1
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  20. 45
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  21. 7
      designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java
  22. 14
      designer-base/src/main/java/com/fr/design/fun/ChartWidgetOptionProvider.java
  23. 9
      designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java
  24. 7
      designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java
  25. 4
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java
  26. 29
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractChartWidgetOptionProvider.java
  27. 5
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java
  28. 6
      designer-base/src/main/java/com/fr/design/gui/frpane/EditingStringListPane.java
  29. 21
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  30. 9
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  31. 12
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  32. 46
      designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java
  33. 12
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  34. 10
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  35. 7
      designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java
  36. 57
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  37. 2
      designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java
  38. 25
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  39. 17
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  40. 1
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java
  41. 6
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  42. 72
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  43. 21
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java
  44. 2
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java
  45. 26
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePane.java
  46. 28
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  47. 17
      designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java
  48. 10
      designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java
  49. 68
      designer-base/src/main/java/com/fr/design/ui/Assistant.java
  50. 130
      designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java
  51. 147
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  52. 85
      designer-base/src/main/java/com/fr/design/ui/NxComplexInterceptRequestCallback.java
  53. 134
      designer-base/src/main/java/com/fr/design/ui/NxInterceptRequestCallback.java
  54. 198
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  55. 4
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  56. 15
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java
  57. 15
      designer-base/src/main/java/com/fr/design/upm/exec/UpmBrowserExecutor.java
  58. 6
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java
  59. 68
      designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java
  60. 28
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  61. 1
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  62. BIN
      designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png
  63. 47
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java
  64. 25
      designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java
  65. 3
      designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java
  66. 39
      designer-base/src/test/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePaneTest.java
  67. 13
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  68. 90
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  69. 104
      designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java
  70. 291
      designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java
  71. 1
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  72. 50
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  73. 143
      designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java
  74. 3
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  75. 9
      designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java
  76. 69
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  77. 49
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java
  78. 106
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java
  79. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java
  80. 92
      designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java
  81. 7
      designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java
  82. 4
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java
  83. 21
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java
  84. 1
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java
  85. 19
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java
  86. 3
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java
  87. 27
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java
  88. 71
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  89. 113
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPaneWithGradientBar.java
  90. 3
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java
  91. 25
      designer-chart/src/main/java/com/fr/van/chart/designer/data/OneDimensionalPlotReportDataContentPane.java
  92. 9
      designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartAreaFillColorConditionPane.java
  93. 153
      designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartColumnSeriesColorConditionPane.java
  94. 16
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java
  95. 17
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java
  96. 10
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisScrollPaneWithTypeSelect.java
  97. 44
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  98. 8
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  99. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java
  100. 33
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java
  101. Some files were not shown because too many files have changed in this diff Show More

6
.gitignore vendored

@ -7,4 +7,10 @@
target/ target/
*/build */build
designer-base/${web-inf-path}
designer-chart/${web-inf-path}
designer-form/${web-inf-path}
designer-realize/${web-inf-path}

10
build.gradle

@ -57,10 +57,10 @@ allprojects {
} }
dependencies { dependencies {
implementation 'com.fr.third:jxbrowser:7.5' implementation 'com.fr.third:jxbrowser:6.23'
implementation 'com.fr.third:jxbrowser-swing:7.5' implementation 'com.fr.third:jxbrowser-swing:6.23'
implementation 'com.fr.third:jxbrowser-mac:7.5' implementation 'com.fr.third:jxbrowser-mac:6.23'
implementation 'com.fr.third:jxbrowser-win64:7.5' implementation 'com.fr.third:jxbrowser-win64:6.23'
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'
@ -68,7 +68,7 @@ allprojects {
implementation 'org.apache.tomcat:tomcat-catalina:8.5.32' implementation 'org.apache.tomcat:tomcat-catalina:8.5.32'
implementation 'io.socket:socket.io-client:0.7.0' implementation 'io.socket:socket.io-client:0.7.0'
implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.third:fine-third:' + frVersion
implementation 'com.fr.core:fine-core:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion
implementation 'com.fr.activator:fine-activator:' + frVersion implementation 'com.fr.activator:fine-activator:' + frVersion
implementation 'com.fr.datasource:fine-datasource:' + frVersion implementation 'com.fr.datasource:fine-datasource:' + frVersion
implementation 'com.fr.decision:fine-decision:' + frVersion implementation 'com.fr.decision:fine-decision:' + frVersion

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

@ -8,6 +8,7 @@ import com.fr.design.dialog.FineJOptionPane;
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;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.env.RemoteWorkspace; import com.fr.design.env.RemoteWorkspace;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
@ -18,7 +19,6 @@ import com.fr.design.utils.DesignUtils;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.general.GeneralContext;
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;
@ -30,7 +30,6 @@ import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.rpc.Result; import com.fr.rpc.Result;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -54,6 +53,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
@ -63,8 +63,6 @@ import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { public class EnvChangeEntrance {
private String currentEnvName = "";
public static EnvChangeEntrance getInstance() { public static EnvChangeEntrance getInstance() {
return HOLDER.singleton; return HOLDER.singleton;
} }
@ -75,13 +73,7 @@ public class EnvChangeEntrance {
private EnvChangeEntrance() { private EnvChangeEntrance() {
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
}
});
} }
private boolean envListOkAction(EnvListPane envListPane, PopTipStrategy strategy) { private boolean envListOkAction(EnvListPane envListPane, PopTipStrategy strategy) {
@ -380,15 +372,21 @@ public class EnvChangeEntrance {
* 出现对话框选择使用的工作环境 * 出现对话框选择使用的工作环境
*/ */
public void chooseEnv() { public void chooseEnv() {
chooseEnv(DesignerEnvManager.getEnvManager().getCurEnvName());
}
public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(currentEnvName); envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
envListOkAction(envListPane, PopTipStrategy.LATER); envListOkAction(envListPane, PopTipStrategy.LATER);
// 切换完成后清理密码
updateNotRememberPwdEnv();
} }
@Override @Override
@ -409,7 +407,7 @@ public class EnvChangeEntrance {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
} }
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(currentEnvName); envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@ -418,6 +416,8 @@ public class EnvChangeEntrance {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue())); FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} else {
updateNotRememberPwdEnv();
} }
} }
@ -429,6 +429,34 @@ public class EnvChangeEntrance {
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
/**
* 切换环境后 刷新远程目录需要忘记密码的情况
*/
private void updateNotRememberPwdEnv() {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
Iterator<String> iterator = mgr.getEnvNameIterator();
while (iterator.hasNext()) {
String envName = iterator.next();
DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName);
if (isNotRememberPwd(info)) {
WorkspaceConnectionInfo connection = info.getConnection();
DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo(
connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false));
mgr.putEnv(envName, workspaceInfo);
}
}
}
private boolean isNotRememberPwd(DesignerWorkspaceInfo info) {
if (info != null && info.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo connection = info.getConnection();
return connection != null && !connection.isRememberPwd();
}
return false;
}
/** /**
* 提示显示策略 * 提示显示策略

37
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -8,6 +8,7 @@ import com.fr.base.BaseUtils;
import com.fr.common.annotations.Open; import com.fr.common.annotations.Open;
import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.fun.CellWidgetOptionProvider;
import com.fr.design.fun.ChartWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.MobileWidgetStyleProvider; import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider; import com.fr.design.fun.ParameterWidgetOptionProvider;
@ -193,6 +194,42 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return result.toArray(new WidgetOption[result.size()]); return result.toArray(new WidgetOption[result.size()]);
} }
public Map<Class<? extends Widget>, Class<?>> getChartWidgetOptionsMap() {
Set<ChartWidgetOptionProvider> set = getArray(ChartWidgetOptionProvider.XML_TAG);
Map<Class<? extends Widget>, Class<?>> map = new HashMap<>();
for (ChartWidgetOptionProvider provider : set) {
map.put(provider.classForWidget(), provider.appearanceForWidget());
}
return map;
}
public WidgetOption[] getBeforeChartWidgetOptions() {
return getChartUnits(true);
}
public WidgetOption[] getAfterChartWidgetOptions() {
return getChartUnits(false);
}
private WidgetOption[] getChartUnits(boolean isBefore) {
Set<ChartWidgetOptionProvider> set = getArray(ChartWidgetOptionProvider.XML_TAG);
if (set.isEmpty()) {
return new WidgetOption[0];
}
Set<WidgetOption> result = new HashSet<>();
for (ChartWidgetOptionProvider provider : set) {
if (provider.isBefore() == isBefore) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
BaseUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
result.add(option);
}
}
return result.toArray(new WidgetOption[result.size()]);
}
public WidgetOption[] getCellWidgetOptions() { public WidgetOption[] getCellWidgetOptions() {
Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG); Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG);

7
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -59,7 +59,14 @@ public class SwitchExistEnv extends MenuDef {
*/ */
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final String envName = getName(); final String envName = getName();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
if (selectedEnv.getConnection() != null && !selectedEnv.getConnection().isRememberPwd()) {
// 打开配置目录面板
EnvChangeEntrance.getInstance().chooseEnv(envName);
} else {
EnvChangeEntrance.getInstance().switch2Env(envName); EnvChangeEntrance.getInstance().switch2Env(envName);
} }
} }
} }
}

2
designer-base/src/main/java/com/fr/design/actions/help/AboutDialog.java

@ -76,7 +76,7 @@ public class AboutDialog extends JDialog implements ActionListener {
this.getRootPane().setDefaultButton(okButton); this.getRootPane().setDefaultButton(okButton);
this.setSize(new Dimension(660, 600)); this.setSize(defaultPane.getPreferredSize().width, 600);
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
} }

12
designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java

@ -4,6 +4,7 @@
package com.fr.design.actions.help; package com.fr.design.actions.help;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.GraphHelper;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.BoldFontTextLabel;
@ -36,9 +37,13 @@ public class AboutPane extends JPanel {
private static final String COMPANY_TELEPHONE = CloudCenter.getInstance().acquireUrlByKind("help.compNo"); private static final String COMPANY_TELEPHONE = CloudCenter.getInstance().acquireUrlByKind("help.compNo");
private static final String PRESIDENT_PHONE = CloudCenter.getInstance().acquireUrlByKind("help.PNo"); private static final String PRESIDENT_PHONE = CloudCenter.getInstance().acquireUrlByKind("help.PNo");
private int maxWidth;
public AboutPane() { public AboutPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.maxWidth = GraphHelper.getWidth(getBuildTitle() + GeneralUtils.readFullBuildNO() +
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO") +
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK"));
//center panel //center panel
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
@ -90,6 +95,11 @@ public class AboutPane extends JPanel {
} }
} }
@Override
public Dimension getPreferredSize() {
return new Dimension(this.maxWidth, super.getPreferredSize().height);
}
private void addPhoneAndQQPane(JPanel contentPane) { private void addPhoneAndQQPane(JPanel contentPane) {
BoxCenterAligmentPane boxCenterAlignmentPane; BoxCenterAligmentPane boxCenterAlignmentPane;
// 英文版不显示服务电话和QQ // 英文版不显示服务电话和QQ

14
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -192,29 +192,29 @@ public class AlphaFineConfigPane extends BasicPane {
this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
boolean enabled4Locale = FRContext.isChineseEnv(); boolean enabled4Locale = FRContext.isChineseEnv() && alphaFineConfigManager.isSearchOnLine();
this.searchOnlineCheckbox.setEnabled(enabled4Locale); this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); this.searchOnlineCheckbox.setSelected(enabled4Locale);
this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && enabled4Locale);
this.containDocumentCheckbox.setEnabled(enabled4Locale); this.containDocumentCheckbox.setEnabled(enabled4Locale);
this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && enabled4Locale);
this.containPluginCheckbox.setEnabled(enabled4Locale); this.containPluginCheckbox.setEnabled(enabled4Locale);
this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && enabled4Locale);
this.containRecommendCheckbox.setEnabled(enabled4Locale); this.containRecommendCheckbox.setEnabled(enabled4Locale);
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine()); this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && enabled4Locale);
this.needIntelligentCustomerService.setEnabled(enabled4Locale); this.needIntelligentCustomerService.setEnabled(enabled4Locale);
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());

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

@ -22,7 +22,6 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.parameter.ParameterInputPane; import com.fr.design.parameter.ParameterInputPane;
import com.fr.file.ProcedureConfig; import com.fr.file.ProcedureConfig;
@ -484,15 +483,9 @@ public abstract class DesignTableDataManager {
if (ArrayUtils.isEmpty(parameters)) { if (ArrayUtils.isEmpty(parameters)) {
parameters = tabledata.getParameters(Calculator.createCalculator()); parameters = tabledata.getParameters(Calculator.createCalculator());
} }
final Map<String, Object> parameterMap = new HashMap<>(); Map<String, Object> parameterMap = new HashMap<>();
if (needInputParams(isMustInputParameters, parameters)) { if (needInputParams(isMustInputParameters, parameters)) {
final ParameterInputPane pPane = new ParameterInputPane(parameters); showParaWindow(parameterMap, parameters);
pPane.showSmallWindow(new JFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
} else { } else {
for (ParameterProvider parameter : parameters) { for (ParameterProvider parameter : parameters) {
parameterMap.put(parameter.getName(), parameter.getValue()); parameterMap.put(parameter.getName(), parameter.getValue());
@ -583,15 +576,10 @@ public abstract class DesignTableDataManager {
return storeProcedure.creatLazyDataModel(); return storeProcedure.creatLazyDataModel();
} }
ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure); ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure);
final Map<String, Object> parameterMap = new HashMap<String, Object>(); Map<String, Object> parameterMap = new HashMap<>();
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(inParameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { showParaWindow(parameterMap, inParameters);
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
} }
storeProcedure.setFirstExpand(false); storeProcedure.setFirstExpand(false);
@ -601,6 +589,16 @@ public abstract class DesignTableDataManager {
return DataOperator.getInstance().previewProcedureDataModel(storeProcedure, parameterMap, 0); return DataOperator.getInstance().previewProcedureDataModel(storeProcedure, parameterMap, 0);
} }
private static void showParaWindow(final Map<String, Object> parameterMap, ParameterProvider[] inParameters) {
final ParameterInputPane pPane = new ParameterInputPane(inParameters);
pPane.showSmallWindow(new JFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
public static void setThreadLocal(String value) { public static void setThreadLocal(String value) {
threadLocal.set(value); threadLocal.set(value);
} }

31
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -4,6 +4,7 @@ import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils; import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
@ -37,11 +38,7 @@ import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth; import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.JList; import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
@ -52,9 +49,7 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode; import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -469,6 +464,15 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
* @return 数据集数据 * @return 数据集数据
*/ */
public TableData createSelectTableData() { public TableData createSelectTableData() {
return createSelectTableData(new SelectSqlProcessor() {
@Override
public String createSelectSql(String schema, String tableName, Dialect dialect) {
return DataCoreUtils.createSelectSQL(schema, tableName, dialect);
}
});
}
public TableData createSelectTableData(SelectSqlProcessor sqlProcessor) {
DataBaseItems paras = this.updateBean(); DataBaseItems paras = this.updateBean();
boolean connect = false; boolean connect = false;
com.fr.data.impl.Connection database = DBUtils.checkDBConnection(paras.getDatabaseName()); com.fr.data.impl.Connection database = DBUtils.checkDBConnection(paras.getDatabaseName());
@ -491,11 +495,11 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
TableData tableData = null; TableData tableData = null;
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
tableData = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), tableData = new DBTableData(database, sqlProcessor.createSelectSql(paras.getSchemaName(), paras.getTableName(),
DialectFactory.getDialectByName(paras.getDatabaseName()))); DialectFactory.getDialectByName(paras.getDatabaseName())));
} else { } else {
try { try {
TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); TableData tableDataLocal = new DBTableData(database, sqlProcessor.createSelectSql(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName())));
tableData = DataOperator.getInstance().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP, tableData = DataOperator.getInstance().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP,
DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow()); DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow());
} catch (Exception e) { } catch (Exception e) {
@ -605,6 +609,13 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
}); });
} }
/**
* 数据集选择面板里的生成sql语句的接口
*/
public interface SelectSqlProcessor {
String createSelectSql(String schema, String tableName, Dialect dialect);
}
protected class StringUIComboBox extends UIComboBox { protected class StringUIComboBox extends UIComboBox {
private boolean refreshingModel = false; private boolean refreshingModel = false;

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

@ -60,7 +60,10 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
if (StringUtils.isEmpty(tempName)) { if (StringUtils.isEmpty(tempName)) {
isNamePermitted = false; isNamePermitted = false;
nameableList.stopEditing(); nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips")); FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this),
Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"),
Toolkit.i18nText("Fine-Design_Report_Alert"),
JOptionPane.WARNING_MESSAGE);
setIllegalIndex(editingIndex); setIllegalIndex(editingIndex);
return; return;
} }

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

@ -1,5 +1,6 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.GraphHelper;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr; import com.fr.data.pool.DBCPConnectionPoolAttr;
@ -16,7 +17,9 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.utils.BrowseUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -65,6 +68,7 @@ public class JDBCDefPane extends JPanel {
private UITextField urlTextField; private UITextField urlTextField;
private UITextField userNameTextField; private UITextField userNameTextField;
private JPasswordField passwordTextField; private JPasswordField passwordTextField;
private ActionLabel odbcTipsLink;
// 请不要改动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};
@ -121,6 +125,28 @@ public class JDBCDefPane extends JPanel {
JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
driverPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Driver") + ":")); driverPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Driver") + ":"));
// 选择ODBC数据源的时候的提示链接
JPanel odbcTipsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
odbcTipsLink = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")) {
@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);
}
};
odbcTipsPane.add(odbcTipsLink);
odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height));
odbcTipsLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help");
BrowseUtils.browser(url);
}
});
JPanel driverComboBoxAndTips = new JPanel(new BorderLayout());
driverComboBoxAndTips.add(driverComboBox, BorderLayout.WEST);
driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER);
JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
urlPane.add(new UILabel("URL:")); urlPane.add(new UILabel("URL:"));
@ -141,7 +167,7 @@ public class JDBCDefPane extends JPanel {
JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
passwordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":")); passwordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":"));
Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBox}, {urlPane, urlComPane}, {userPane, userComPane},}; Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane}, {userPane, userComPane},};
double[] rowSize = {p, p, p, p}; double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f, 22}; double[] columnSize = {p, f, 22};
@ -267,6 +293,7 @@ public class JDBCDefPane extends JPanel {
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) { if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return; return;
} }
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator(); Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) { while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next(); Entry<String, DriverURLName[]> entry = jdbc.next();

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

@ -2,8 +2,9 @@ package com.fr.design.dcm;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.ui.ModernUIPane; import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.*; import java.awt.*;
@ -25,13 +26,14 @@ public class UniversalDatabasePane extends BasicPane {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
modernUIPane = new ModernUIPane.Builder<>() modernUIPane = new ModernUIPane.Builder<>()
.withComponent(UniversalDatabaseComponent.KEY) .withComponent(UniversalDatabaseComponent.KEY)
.prepare(params -> { .prepare(new ScriptContextAdapter() {
JsObject window = params.frame().executeJavaScript("window"); @Override
if (window != null) { public void onScriptContextCreated(ScriptContextEvent event) {
window.putProperty("DcmHelper", UniversalDcmBridge.getBridge()); JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DcmHelper", UniversalDcmBridge.getBridge(event.getBrowser()));
} }
return InjectJsCallback.Response.proceed(); })
}).build(); .build();
add(modernUIPane, BorderLayout.CENTER); add(modernUIPane, BorderLayout.CENTER);
} }
} }

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

@ -2,6 +2,8 @@ package com.fr.design.dcm;
import com.fr.decision.webservice.bean.BaseBean; import com.fr.decision.webservice.bean.BaseBean;
import com.fr.design.bridge.exec.JSBridge; import com.fr.design.bridge.exec.JSBridge;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSObject;
/** /**
* @author richie * @author richie
@ -11,18 +13,18 @@ import com.fr.design.bridge.exec.JSBridge;
*/ */
public class UniversalDcmBridge { public class UniversalDcmBridge {
public static UniversalDcmBridge getBridge() { public static UniversalDcmBridge getBridge(Browser browser) {
return new UniversalDcmBridge(); return new UniversalDcmBridge(browser);
} }
private JSObject window;
private UniversalDcmBridge() { private UniversalDcmBridge(Browser browser) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
} }
/** /**
* 获取所有的数据连接 * 获取所有的数据连接
*
* @return 数据连接集合 * @return 数据连接集合
*/ */
@JSBridge @JSBridge

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

@ -1,6 +1,7 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.stable.StringUtils;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -279,8 +280,11 @@ public class FineJOptionPane extends JOptionPane {
dialog.show(); dialog.show();
dialog.dispose(); dialog.dispose();
Object value = pane.getInputValue(); //点击取消按钮,返回null
if (StringUtils.equals((String) pane.getValue(), OPTION_OK_CANCEL[1]))
return null;
Object value = pane.getInputValue();
if (value == UNINITIALIZED_VALUE) { if (value == UNINITIALIZED_VALUE) {
return null; return null;
} }

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

@ -1,16 +1,39 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.SecurityToolbox; import com.fr.security.SecurityToolbox;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import java.util.HashSet;
import java.util.Set;
public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private static final Set<String> FILTER_SET = new HashSet<>();
private static final String HTTPS = "https://";
private static final String HTTP = "http://";
private static final String DEFAULT_SERVLET_NAME = "decision";
private static final String PATH = ProjectConstants.FORWARD_SLASH + ProjectConstants.WEBAPP_NAME + ProjectConstants.FORWARD_SLASH + DEFAULT_SERVLET_NAME;
private static final String HOST_NAME = "127.0.0.1";
private static final String LOCAL_HOTS_NAME = "localhost";
private static final String QUOTATION = ":";
private static final String PORT = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
static {
FILTER_SET.add(HTTP + HOST_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTPS + HOST_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTP + LOCAL_HOTS_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTPS + LOCAL_HOTS_NAME + QUOTATION + PORT + PATH);
}
private String name; private String name;
private String remindTime; private String remindTime;
@ -72,7 +95,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n"));
String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd);
} }
} }
} }
@ -89,6 +113,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath()); writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey()); writer.attr("certSecretKey", connection.getCertSecretKey());
writer.attr("rememberPwd", connection.isRememberPwd());
writer.end(); writer.end();
} }
} }
@ -107,6 +132,10 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override @Override
public boolean checkValid() { public boolean checkValid() {
boolean result = false; boolean result = false;
if (FILTER_SET.contains(connection.getUrl())) {
FineLoggerFactory.getLogger().error("url is same with local designer");
return result;
}
try { try {
result = WorkContext.getConnector().testConnection(connection); result = WorkContext.getConnector().testConnection(connection);
} catch (Exception e) { } catch (Exception e) {

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

@ -11,7 +11,6 @@ import com.fr.general.CommonIOUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -32,7 +31,6 @@ import java.awt.Window;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.net.HttpURLConnection;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
/** /**
@ -154,6 +152,7 @@ public class WebViewDlgHelper {
* @param keyword * @param keyword
* @param data * @param data
*/ */
@Deprecated
public static void showPluginInStore(String keyword, String data) { public static void showPluginInStore(String keyword, String data) {
PluginWebBridge.getHelper().showResultInStore(keyword, data); PluginWebBridge.getHelper().showResultInStore(keyword, data);
createPluginDialog(); createPluginDialog();

20
designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java

@ -1,10 +1,13 @@
package com.fr.design.extra.exe; package com.fr.design.extra.exe;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.PluginConstants; import com.fr.design.extra.PluginConstants;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpToolbox;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.Locale;
/** /**
* Created by vito on 16/5/16. * Created by vito on 16/5/16.
@ -28,14 +31,17 @@ public class GetPluginCategoriesExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.category"); Locale locale = DesignerEnvManager.getEnvManager().getLanguage();
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.category") + "&locale=" + locale.toString();
if (StringUtils.isNotEmpty(url)) { if (StringUtils.isNotEmpty(url)) {
HttpClient httpClient = new HttpClient(url); try {
result = httpClient.getResponseText(); result = HttpToolbox.get(url);
} else { return;
result = PluginConstants.CONNECTION_404; } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
}
result = PluginConstants.CONNECTION_404;
} }
} }
}; };

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

@ -422,5 +422,4 @@ public class HistoryTemplateListCache implements CallbackEvent {
jt.refreshResource(); jt.refreshResource();
} }
} }
} }

45
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -246,13 +246,45 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
public class DoubleClick extends MouseAdapter { public class DoubleClick extends MouseAdapter {
String singlePressContent;
String doublePressContent;
@Override
public void mousePressed(MouseEvent e) {
int index = tipsList.getSelectedIndex();
if (index != -1) {
if (e.getClickCount() == 1) {
singlePressContent = (String) listModel.getElementAt(index);
} else if (e.getClickCount() == 2) {
doublePressContent = (String) listModel.getElementAt(index);
}
}
}
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseReleased(MouseEvent e) {
int index = tipsList.getSelectedIndex(); int index = tipsList.getSelectedIndex();
if (index != -1) { if (index != -1) {
String currentLineContent = (String) listModel.getElementAt(index); if (e.getClickCount() == 1) {
if (e.getClickCount() == 2) { if (ComparatorUtils.equals((String) listModel.getElementAt(index), singlePressContent)) {
singleClickActuator(singlePressContent);
}
} else if (e.getClickCount() == 2) {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) {
doubleClickActuator(doublePressContent);
}
}
}
}
private void singleClickActuator(String currentLineContent) {
refreshDescriptionTextArea(currentLineContent);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
private void doubleClickActuator(String currentLineContent) {
if (ifHasBeenWriten == 0) { if (ifHasBeenWriten == 0) {
formulaTextArea.setForeground(Color.black); formulaTextArea.setForeground(Color.black);
formulaTextArea.setText(""); formulaTextArea.setText("");
@ -276,13 +308,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
insertPosition = position; insertPosition = position;
ifHasBeenWriten = 1; ifHasBeenWriten = 1;
listModel.removeAllElements(); listModel.removeAllElements();
} else if (e.getClickCount() == 1) {
refreshDescriptionTextArea(currentLineContent);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
}
} }
} }

7
designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java

@ -18,4 +18,11 @@ public interface CellExpandAttrPanelProvider extends Mutable {
* @return 创建单元格属性-扩展设置中的额外面板 * @return 创建单元格属性-扩展设置中的额外面板
*/ */
BasicBeanPane<TemplateCellElement> createPanel(); BasicBeanPane<TemplateCellElement> createPanel();
/**
* 是否应该展示
*
* @return return {@code true} if extra panel is displayable
*/
boolean isDisplayable();
} }

14
designer-base/src/main/java/com/fr/design/fun/ChartWidgetOptionProvider.java

@ -0,0 +1,14 @@
package com.fr.design.fun;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-06-12
*/
public interface ChartWidgetOptionProvider extends ParameterWidgetOptionProvider {
String XML_TAG = "ChartWidgetOptionProvider";
//在图表区域的开头还是结尾插入
boolean isBefore();
}

9
designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java

@ -25,13 +25,10 @@ public interface FormAdaptiveConfigUIProcessor extends Immutable {
ShortCut getConfigShortCut(JTemplate jTemplate); ShortCut getConfigShortCut(JTemplate jTemplate);
/** /**
* 绘制自适应下报表块在表单界面中显示图片 * 是否开启表单滑块缩放功能
* @param size 绘制尺寸 * @return 是否开启表单滑块缩放
* @param elementCasePane 报表块内容对象
* @return 自适应下报表块在表单界面中显示的图片
*/ */
BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane); boolean openFormSliderZoom();
/** /**
* 获取新自适应下字体显示的dpi * 获取新自适应下字体显示的dpi

7
designer-base/src/main/java/com/fr/design/fun/FormWidgetOptionProvider.java

@ -16,4 +16,11 @@ public interface FormWidgetOptionProvider extends ParameterWidgetOptionProvider
*/ */
boolean isContainer(); boolean isContainer();
/**
* 如果是布局容器要实现粘贴到容器中的操作
* @param t
* @param <T> 泛型参数 表示选中的组件 一般为FormSelection
*/
<T> void paste2Container(T t);
} }

4
designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java

@ -36,4 +36,8 @@ public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelP
public BasicBeanPane<TemplateCellElement> createPanel() { public BasicBeanPane<TemplateCellElement> createPanel() {
return null; return null;
} }
public boolean isDisplayable() {
return true;
}
} }

29
designer-base/src/main/java/com/fr/design/fun/impl/AbstractChartWidgetOptionProvider.java

@ -0,0 +1,29 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ChartWidgetOptionProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-06-12
*/
@API(level = ChartWidgetOptionProvider.CURRENT_LEVEL)
public abstract class AbstractChartWidgetOptionProvider extends AbstractProvider implements ChartWidgetOptionProvider {
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public boolean isBefore() {
return false;
}
}

5
designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormWidgetOptionProvider.java

@ -25,4 +25,9 @@ public abstract class AbstractFormWidgetOptionProvider extends AbstractProvider
public boolean isContainer() { public boolean isContainer() {
return false; return false;
} }
@Override
public <T> void paste2Container(T t) {
// do nothing
}
} }

6
designer-base/src/main/java/com/fr/design/gui/frpane/EditingStringListPane.java

@ -3,6 +3,7 @@ package com.fr.design.gui.frpane;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
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.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.JListUtils; import com.fr.design.utils.gui.JListUtils;
@ -150,7 +151,10 @@ public abstract class EditingStringListPane extends BasicBeanPane<List<String>>
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Object selected = jlist.getSelectedValue(); Object selected = jlist.getSelectedValue();
if (selected != null) { if (selected != null) {
int re = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(EditingStringListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sure_To_Delete") + selected.toString() + "?"); int re = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(EditingStringListPane.this),
Toolkit.i18nText("Fine-Design_Basic_Sure_To_Delete") + selected.toString() + "?",
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
JOptionPane.OK_CANCEL_OPTION);
if (re == JOptionPane.OK_OPTION) { if (re == JOptionPane.OK_OPTION) {
JListUtils.removeSelectedListItems(jlist); JListUtils.removeSelectedListItems(jlist);
} }

21
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -11,6 +11,10 @@ import com.fr.general.IOUtils;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -22,10 +26,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class UICheckListPopup extends UIPopupMenu { public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>(); private List<ActionListener> listeners = new ArrayList<ActionListener>();
@ -59,7 +59,7 @@ public class UICheckListPopup extends UIPopupMenu {
public void setMaxDisplayNumber(int maxDisplayNumber) { public void setMaxDisplayNumber(int maxDisplayNumber) {
this.maxDisplayNumber = maxDisplayNumber; this.maxDisplayNumber = maxDisplayNumber;
addCheckboxValues(values); addCheckboxValues();
} }
private void initComponent() { private void initComponent() {
@ -71,10 +71,15 @@ public class UICheckListPopup extends UIPopupMenu {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(jScrollPane, BorderLayout.CENTER); this.add(jScrollPane, BorderLayout.CENTER);
addCheckboxValues(values); addCheckboxValues();
}
public void refreshCheckboxValues(Object[] values){
this.values = values;
addCheckboxValues();
} }
public void addCheckboxValues(Object[] value) { private void addCheckboxValues() {
checkboxPane.removeAll(); checkboxPane.removeAll();
checkBoxList.clear(); checkBoxList.clear();
@ -82,7 +87,7 @@ public class UICheckListPopup extends UIPopupMenu {
if (supportSelectAll) { if (supportSelectAll) {
addOneCheckValue(SELECT_ALL); addOneCheckValue(SELECT_ALL);
} }
for (Object checkValue : value) { for (Object checkValue : values) {
addOneCheckValue(checkValue); addOneCheckValue(checkValue);
} }
addSelectListener(); addSelectListener();

9
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -17,6 +17,9 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -29,9 +32,6 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/** /**
* 设计器下拉复选框组件 * 设计器下拉复选框组件
@ -209,7 +209,8 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
*/ */
public void refreshCombo(Object[] value) { public void refreshCombo(Object[] value) {
this.values = value; this.values = value;
this.popup.addCheckboxValues(value); //CHART-13666 控件之前的刷新有bug,没有刷新popup中values的值,导致数组越界
this.popup.refreshCheckboxValues(value);
} }
/** /**

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

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

46
designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java

@ -21,6 +21,8 @@ import com.fr.general.IOUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -82,6 +84,20 @@ public class JSContentPane extends BasicPane {
UIScrollPane sp = new UIScrollPane(contentTextArea); UIScrollPane sp = new UIScrollPane(contentTextArea);
this.add(sp, BorderLayout.CENTER); this.add(sp, BorderLayout.CENTER);
contentTextArea.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// 获得焦点时 安装
installAutoCompletion();
}
@Override
public void focusLost(FocusEvent e) {
// 失去焦点时 卸载
uninstallAutoCompletion();
}
});
UILabel funNameLabel2 = new UILabel(); UILabel funNameLabel2 = new UILabel();
funNameLabel2.setText("}"); funNameLabel2.setText("}");
this.add(funNameLabel2, BorderLayout.SOUTH); this.add(funNameLabel2, BorderLayout.SOUTH);
@ -91,12 +107,10 @@ public class JSContentPane extends BasicPane {
return KeyStroke.getKeyStroke(ks.replace("+", "pressed")); return KeyStroke.getKeyStroke(ks.replace("+", "pressed"));
} }
@Override /**
protected String title4PopupWindow() { * 注册安装 自动补全监听
return "JS"; */
} private void installAutoCompletion() {
public void populate(String js) {
if (ac == null) { if (ac == null) {
CompletionProvider provider = createCompletionProvider(); CompletionProvider provider = createCompletionProvider();
ac = new AutoCompletion(provider); ac = new AutoCompletion(provider);
@ -105,16 +119,28 @@ public class JSContentPane extends BasicPane {
ac.setTriggerKey(convert2KeyStroke(shortCuts)); ac.setTriggerKey(convert2KeyStroke(shortCuts));
ac.install(contentTextArea); ac.install(contentTextArea);
} }
this.contentTextArea.setText(js);
} }
public String update() { /**
* 卸载移除 自动补全监听
*/
private void uninstallAutoCompletion() {
if (ac != null) { if (ac != null) {
this.ac.uninstall(); ac.uninstall();
ac = null; ac = null;
} }
}
@Override
protected String title4PopupWindow() {
return "JS";
}
public void populate(String js) {
this.contentTextArea.setText(js);
}
public String update() {
return this.contentTextArea.getText(); return this.contentTextArea.getText();
} }

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

@ -1106,7 +1106,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
int index = HistoryTemplateListCache.getInstance().contains(tplFile); int index = HistoryTemplateListCache.getInstance().contains(tplFile);
if (index != -1) { if (index != -1) {
JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index); JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index);
if (!(jt instanceof JVirtualTemplate)) { if (jt instanceof JVirtualTemplate) {
// 如果是JVirtualTemplate 创建真实JTemplate
JTemplate realJTemplate = JTemplateFactory.createJTemplate(tplFile);
if (realJTemplate == null) {
return;
}
// 由JVirtualTemplate激活真实JTemplate 本质在historyList中进行替换
// 同时 realJTemplate被管理起来 不需要主动释放 关闭时会自动释放
jt.activeJTemplate(index, realJTemplate);
return;
} else {
jt.activeOldJTemplate(); jt.activeOldJTemplate();
return; return;
} }

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

@ -1,6 +1,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.FRContext;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -66,7 +67,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private JPanel leftPane; private JPanel leftPane;
private JPanel rightPane; private JPanel rightPane;
private FixedPopupPane currentPopupPane; private FixedPopupPane currentPopupPane;
private static final int CONTAINER_WIDTH = 286; private static final int CONTAINER_WIDTH = containerWidth();
private static final int TAB_WIDTH = 38; private static final int TAB_WIDTH = 38;
private static final int TAB_BUTTON_WIDTH = 32; private static final int TAB_BUTTON_WIDTH = 32;
private static final int TAB_BUTTON_HEIGHT = 28; private static final int TAB_BUTTON_HEIGHT = 28;
@ -107,6 +108,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private PropertyMode currentMode; // 当前模式(根据不同模式,显示不同的可用面板) private PropertyMode currentMode; // 当前模式(根据不同模式,显示不同的可用面板)
private static int containerWidth() {
if (FRContext.isChineseEnv()) {
return UIEastResizableContainer.MIN_CONTAINER_WIDTH;
}
return UIEastResizableContainer.MAX_CONTAINER_WIDTH;
}
/** /**
* 得到实例 * 得到实例
* *

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

@ -88,6 +88,8 @@ public class JFormSliderPane extends JPanel {
private UIRadioButton customButton; private UIRadioButton customButton;
//拖动条处理和button、直接输入不一样 //拖动条处理和button、直接输入不一样
private boolean isButtonOrIsTxt = true; private boolean isButtonOrIsTxt = true;
//是否选中指定的几个缩放等级,避免触发不必要的事件
private boolean selectSpecified = false;
private FormPopupPane dialog; private FormPopupPane dialog;
private int upButtonX; private int upButtonX;
private JPanel dialogContentPanel; private JPanel dialogContentPanel;
@ -288,6 +290,9 @@ public class JFormSliderPane extends JPanel {
refreshBottun(val); refreshBottun(val);
JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
textField.setCaretPosition(showValSpinner.getValue().toString().length()); textField.setCaretPosition(showValSpinner.getValue().toString().length());
if (!selectSpecified) {
customButton.setSelected(true);
}
} }
}; };
@ -317,7 +322,9 @@ public class JFormSliderPane extends JPanel {
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
JRadioButton temp = (JRadioButton) e.getSource(); JRadioButton temp = (JRadioButton) e.getSource();
if (temp.isSelected()) { if (temp.isSelected()) {
selectSpecified = true;
showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%"))));
selectSpecified = false;
} }
} }
}; };

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

@ -28,6 +28,7 @@ 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;
import com.fr.design.fun.PropertyItemPaneProvider;
import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
@ -55,6 +56,14 @@ import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.plugin.observer.PluginListenerRegistration;
import com.fr.report.cell.Elem; import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.cellattr.CellImage;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -100,7 +109,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
public int resolution = ScreenResolution.getScreenResolution(); public int resolution = ScreenResolution.getScreenResolution();
private PluginEventListener pluginListener;
public JTemplate() { public JTemplate() {
initAndStartPlugin();
} }
public JTemplate(T t, String defaultFileName) { public JTemplate(T t, String defaultFileName) {
@ -129,8 +141,50 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
designModel = createDesignModel(); designModel = createDesignModel();
consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile));
initAndStartPlugin();
}
private void initAndStartPlugin() {
initPluginPane();
startListenPlugin();
}
private void startListenPlugin() {
PluginFilter filter = new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PropertyItemPaneProvider.XML_TAG);
}
};
this.pluginListener = new PluginEventListener(PropertyItemPaneProvider.LAST) {
@Override
public void on(PluginEvent event) {
PluginContext context = event.getContext();
PluginRuntime runtime = context.getRuntime();
Set<PropertyItemPaneProvider> providers = runtime.get(PropertyItemPaneProvider.XML_TAG);
for (PropertyItemPaneProvider provider : providers) {
addPane(provider);
}
}
};
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter);
}
private void initPluginPane() {
ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<PropertyItemPaneProvider> providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG);
for (PropertyItemPaneProvider provider : providers) {
addPane(provider);
}
} }
protected <R> void addPane(PropertyItemPaneProvider provider) {
// do nothing
}
void onGetFocus() { void onGetFocus() {
consumeTimer.start(); consumeTimer.start();
} }
@ -251,7 +305,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* 模板关闭时 * 模板关闭时
*/ */
public void whenClose() { public void whenClose() {
// do nothing // stop的时候 pluginListener 和 PluginFilter 都会移除
PluginListenerRegistration.getInstance().stopListen(this.pluginListener);
} }
/** /**

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

@ -211,6 +211,8 @@ public class JVirtualTemplate extends JTemplate {
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
historyList.set(index, jt); historyList.set(index, jt);
DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt); DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt);
// 虚拟模板JVirtualTemplate被激活后 由真实的JTemplate替换 此时调用whenClose 防止JVirtualTemplate无法释放
this.whenClose();
} }
@Override @Override

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

@ -54,6 +54,8 @@ public class ChartInfo extends AbstractPointInfo {
private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount"; private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount";
private static final String ATTR_IS_NEW = "isNew"; private static final String ATTR_IS_NEW = "isNew";
private static final String ATTR_IS_REUSE = "isReuse"; private static final String ATTR_IS_REUSE = "isReuse";
private static final String ATTR_AUTO_CHART_CREATE_TIME = "autoChartCreateTime";
private static final String ATTR_AUTO_CHART_ENSURE_TIME = "autoChartEnsureTime";
private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数 private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数
@ -122,10 +124,10 @@ public class ChartInfo extends AbstractPointInfo {
} }
public static ChartInfo newInstance(ChartProvider chartProvider) { public static ChartInfo newInstance(ChartProvider chartProvider) {
return newInstance(chartProvider, null, false, false); return newInstance(chartProvider, null, false, false, false);
} }
public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse) { public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse, boolean isAutoChart) {
HashMap<String, String> chartConsumingMap = new HashMap<>(); HashMap<String, String> chartConsumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
@ -163,6 +165,13 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0"); chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0");
chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew)); chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew));
chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse)); chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse));
if (isAutoChart) {
chartConsumingMap.put(ATTR_AUTO_CHART_CREATE_TIME, createTime);
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, typeTime);
} else {
chartConsumingMap.put(ATTR_AUTO_CHART_CREATE_TIME, StringUtils.EMPTY);
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, StringUtils.EMPTY);
}
ChartInfo chartInfo = new ChartInfo(chartId, templateId, book); ChartInfo chartInfo = new ChartInfo(chartId, templateId, book);
chartInfo.chartConsumingMap = chartConsumingMap; chartInfo.chartConsumingMap = chartConsumingMap;
@ -202,6 +211,9 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_OVER_CHART_TYPE_COUNT, chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT)); writer.attr(ATTR_OVER_CHART_TYPE_COUNT, chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT));
writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW)); writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW));
writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE)); writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE));
writer.attr(ATTR_AUTO_CHART_CREATE_TIME, chartConsumingMap.get(ATTR_AUTO_CHART_CREATE_TIME));
writer.attr(ATTR_AUTO_CHART_ENSURE_TIME, chartConsumingMap.get(ATTR_AUTO_CHART_ENSURE_TIME));
writer.end(); writer.end();
chartConfigInfo.writeXML(writer); chartConfigInfo.writeXML(writer);
@ -238,6 +250,8 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, reader.getAttrAsString(ATTR_OVER_CHART_TYPE_COUNT, "0")); chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, reader.getAttrAsString(ATTR_OVER_CHART_TYPE_COUNT, "0"));
chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_AUTO_CHART_CREATE_TIME, reader.getAttrAsString(ATTR_AUTO_CHART_CREATE_TIME, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, reader.getAttrAsString(ATTR_AUTO_CHART_ENSURE_TIME, StringUtils.EMPTY));
} }
if (ChartConfigInfo.XML_TAG.equals(name)) { if (ChartConfigInfo.XML_TAG.equals(name)) {
this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo()); this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo());
@ -276,6 +290,10 @@ public class ChartInfo extends AbstractPointInfo {
} }
public void updateChartType(ChartProvider chartProvider) { public void updateChartType(ChartProvider chartProvider) {
updateChartType(chartProvider, false);
}
public void updateChartType(ChartProvider chartProvider, boolean isAutoChart) {
String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime);
@ -285,6 +303,9 @@ public class ChartInfo extends AbstractPointInfo {
String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT); String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT);
count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1); count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count); chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count);
if (isAutoChart) {
chartConsumingMap.put(ATTR_AUTO_CHART_ENSURE_TIME, typeTime);
}
resetChartConfigInfo(chartProvider); resetChartConfigInfo(chartProvider);
} }

17
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java

@ -12,6 +12,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -49,18 +50,22 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
} }
public void collection(ChartProvider chartProvider, String createTime) { public void collection(ChartProvider chartProvider, String createTime) {
collection(chartProvider, createTime, false); collection(chartProvider, createTime, false, false);
}
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) {
collection(chartProvider, createTime, isReuse, false);
} }
/** /**
* 新建图表保存状态 * 新建图表保存状态
*/ */
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) { public void collection(ChartProvider chartProvider, String createTime, boolean isReuse, boolean isAutoChart) {
String chartId = chartProvider.getChartUuid(); String chartId = chartProvider.getChartUuid();
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
return; return;
} }
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse); ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse, isAutoChart);
chartInfoCacheMap.put(chartId, chartInfo); chartInfoCacheMap.put(chartId, chartInfo);
} }
@ -116,6 +121,10 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
* 图表类型变化更新类型和类型确认时间 * 图表类型变化更新类型和类型确认时间
*/ */
public void updateChartTypeTime(ChartProvider chartProvider, String oldType) { public void updateChartTypeTime(ChartProvider chartProvider, String oldType) {
updateChartTypeTime(chartProvider, oldType, false);
}
public void updateChartTypeTime(ChartProvider chartProvider, String oldType, boolean isAutoChart) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return; return;
} }
@ -123,7 +132,7 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType); ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType);
//更新类型确认时间和类型 //更新类型确认时间和类型
chartInfo.updateChartType(chartProvider); chartInfo.updateChartType(chartProvider, isAutoChart);
//重置计数 //重置计数
chartInfo.resetIdleDayCount(); chartInfo.resetIdleDayCount();

1
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java

@ -93,6 +93,7 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void clearMessage() { public void clearMessage() {
INFONUM = ERRORNUM = SERVERNUM = 0; INFONUM = ERRORNUM = SERVERNUM = 0;
LogMessageBar.getInstance().clear();
changeLabel(); changeLabel();
} }

6
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.loghandler;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.StringUtils;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -63,6 +64,11 @@ public class LogMessageBar extends JPanel {
repaint(); repaint();
} }
public void clear() {
messageLabel.setText(StringUtils.EMPTY);
repaint();
}
public void setLoggerBarWidth(int width) { public void setLoggerBarWidth(int width) {
this.width = width; this.width = width;
} }

72
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -5,6 +5,7 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -21,14 +22,14 @@ import com.fr.stable.Constants;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> { public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@ -42,6 +43,8 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private Widget widget; private Widget widget;
private MobileStyleCustomDefinePane customBeanPane; private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz; private Class<? extends MobileStyle> mobileStyleClazz;
private UIComboBox customCombo;
private JPanel settingPane;
private ColorSelectBox colorSelectBox; private ColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241); private Color titleColor = new Color(47, 142, 241);
private JPanel commomPane; private JPanel commomPane;
@ -62,19 +65,21 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override @Override
public void populateBean(MobileStyle ob) { public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob); this.customBeanPane.populateBean(ob);
if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor()); customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0);
if(ob.getCommonBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getCommonBackground()).getColor());
} }
borderType.setSelectedLineStyle(ob.getBorderType()); borderType.setSelectedLineStyle(ob.getCommonBorderType());
if (ob.getBorderColor() != null) { if (ob.getCommonBorderColor() != null) {
borderColor.setSelectObject(ob.getBorderColor()); borderColor.setSelectObject(ob.getCommonBorderColor());
} }
borderRadius.setValue(ob.getBorderRadius()); borderRadius.setValue(ob.getCommonBorderRadius());
if (ob.getIconColor() != null) { if (ob.getCommonIconColor() != null) {
iconColor.setSelectObject(ob.getIconColor()); iconColor.setSelectObject(ob.getCommonIconColor());
} }
if (ob.getFont() != null) { if (ob.getCommonFont() != null) {
fontConfigPane.populateBean(ob.getFont()); fontConfigPane.populateBean(ob.getCommonFont());
} }
} }
@ -83,12 +88,13 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get(); MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject())); mobileStyle.setCommonCustom(customCombo.getSelectedIndex() == 1);
mobileStyle.setBorderType(borderType.getSelectedLineStyle()); mobileStyle.setCommonBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
mobileStyle.setBorderColor(borderColor.getSelectObject()); mobileStyle.setCommonBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderRadius(borderRadius.getValue()); mobileStyle.setCommonBorderColor(borderColor.getSelectObject());
mobileStyle.setIconColor(iconColor.getSelectObject()); mobileStyle.setCommonBorderRadius(borderRadius.getValue());
mobileStyle.setFont(fontConfigPane.updateBean()); mobileStyle.setCommonIconColor(iconColor.getSelectObject());
mobileStyle.setCommonFont(fontConfigPane.updateBean());
return mobileStyle; return mobileStyle;
} }
@ -126,6 +132,23 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
commomPane.setBorder(titledBorder); commomPane.setBorder(titledBorder);
this.add(commomPane, BorderLayout.NORTH); this.add(commomPane, BorderLayout.NORTH);
customCombo = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Mobile_Default"), Toolkit.i18nText("Fine-Design_Mobile_Custom")});
customCombo.setSelectedIndex(0);
customCombo.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
customCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean custom = customCombo.getSelectedIndex() == 1;
settingPane.setVisible(custom);
}
});
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Attribute_Settings")), customCombo));
settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
settingPane.setVisible(false);
commomPane.add(settingPane);
createBackgroundPane(); createBackgroundPane();
createBorderPane(); createBorderPane();
createIconSettingPane(); createIconSettingPane();
@ -136,7 +159,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH); colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH);
JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox); JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox);
commomPane.add(backgroundPane); settingPane.add(backgroundPane);
} }
private void createBorderPane() { private void createBorderPane() {
@ -146,19 +169,20 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20)); borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
} }
private void createIconSettingPane() { private void createIconSettingPane() {
iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor)); iconColor.setSelectObject(new Color(31,173,229));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
} }
private void createFontPane() { private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane(); fontConfigPane = new MobileStyleFontConfigPane();
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
} }
private void createCustomPane() { private void createCustomPane() {

21
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
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;
@ -16,7 +17,6 @@ import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
@ -31,7 +31,6 @@ public class MobileStyleFontConfigPane extends JPanel {
public static Vector<Integer> getFontSizes() { public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>(); Vector<Integer> FONT_SIZES = new Vector<Integer>();
FONT_SIZES.add(FONT_NONE);
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i); FONT_SIZES.add(i);
} }
@ -39,7 +38,7 @@ public class MobileStyleFontConfigPane extends JPanel {
} }
private UIComboBox fontSizeComboBox; private UIComboBox fontSizeComboBox;
private UIToggleButton underline; private UIColorButton color;
private UIToggleButton italic; private UIToggleButton italic;
private UIToggleButton bold; private UIToggleButton bold;
@ -51,10 +50,10 @@ public class MobileStyleFontConfigPane extends JPanel {
fontSizeComboBox = new UIComboBox(); fontSizeComboBox = new UIComboBox();
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes())); fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes()));
fontSizeComboBox.setSelectedItem(0); fontSizeComboBox.setSelectedItem(16);
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setRenderer(new LineCellRenderer()); fontSizeComboBox.setRenderer(new LineCellRenderer());
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); color = new UIColorButton();
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
@ -62,7 +61,7 @@ public class MobileStyleFontConfigPane extends JPanel {
this.setButtonsSize(BUTTON_SIZE); this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{ Component[] components_font = new Component[]{
fontSizeComboBox, underline, italic, bold fontSizeComboBox, color, italic, bold
}; };
JPanel buttonPane = new JPanel(new BorderLayout()); JPanel buttonPane = new JPanel(new BorderLayout());
@ -73,13 +72,13 @@ public class MobileStyleFontConfigPane extends JPanel {
} }
private void setButtonsTips() { private void setButtonsTips() {
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); color.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic")); italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold")); bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold"));
} }
private void setButtonsSize(Dimension size) { private void setButtonsSize(Dimension size) {
underline.setPreferredSize(size); color.setPreferredSize(size);
italic.setPreferredSize(size); italic.setPreferredSize(size);
bold.setPreferredSize(size); bold.setPreferredSize(size);
} }
@ -87,9 +86,9 @@ public class MobileStyleFontConfigPane extends JPanel {
public void populateBean(FRFont frFont) { public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize()); fontSizeComboBox.setSelectedItem(frFont.getSize());
color.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold()); bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic()); italic.setSelected(frFont.isItalic());
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE);
} }
public FRFont updateBean() { public FRFont updateBean() {
@ -100,8 +99,8 @@ public class MobileStyleFontConfigPane extends JPanel {
FRFont.DEFAULT_FONTNAME, FRFont.DEFAULT_FONTNAME,
style, style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
Color.BLACK, color.getColor(),
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE Constants.LINE_NONE
); );
} }

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

@ -109,7 +109,7 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
UILabel tabStyleLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Style")); UILabel tabStyleLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Style"));
tabStyleLabel.setPreferredSize(new Dimension(55, 20)); tabStyleLabel.setPreferredSize(new Dimension(55, 20));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tabStyleLabel, custom}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tabStyleLabel, custom}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
jPanel.setPreferredSize(new Dimension(200, 20)); jPanel.setPreferredSize(new Dimension(212, 20));
outPanel.add(jPanel); outPanel.add(jPanel);
scrollPanel.add(outPanel, BorderLayout.NORTH); scrollPanel.add(outPanel, BorderLayout.NORTH);

26
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePane.java

@ -33,6 +33,8 @@ public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane {
private UnsignedIntUISpinner paddingLeftSpinner; private UnsignedIntUISpinner paddingLeftSpinner;
private UnsignedIntUISpinner paddingRightSpinner; private UnsignedIntUISpinner paddingRightSpinner;
private UnsignedIntUISpinner paddingTopSpinner;
private UnsignedIntUISpinner paddingBottomSpinner;
private NewColorSelectBox initialBackgroundColorBox; private NewColorSelectBox initialBackgroundColorBox;
private NewColorSelectBox selectedBackgroundColorBox; private NewColorSelectBox selectedBackgroundColorBox;
@ -77,6 +79,15 @@ public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane {
} }
private JPanel createPaddingConfPane() { private JPanel createPaddingConfPane() {
this.paddingTopSpinner = new UnsignedIntUISpinner(0, 30, 1, UniteStyle.DEFAULT_PADDING_TOP);
this.paddingTopSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT));
this.paddingBottomSpinner = new UnsignedIntUISpinner(0, 30, 1, UniteStyle.DEFAULT_PADDING_BOTTOM);
this.paddingBottomSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT));
UILabel paddingTopLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Base_Top") + ":", SwingConstants.RIGHT);
paddingTopLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT));
UILabel paddingBottomLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Base_Bottom") + ":", SwingConstants.RIGHT);
paddingBottomLabel.setPreferredSize(new Dimension(LABEL_WIDTH / 2, LINE_COMPONENT_HEIGHT));
this.paddingLeftSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_PADDING_LEFT); this.paddingLeftSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_PADDING_LEFT);
this.paddingLeftSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT)); this.paddingLeftSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT));
@ -86,11 +97,12 @@ public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane {
UILabel paddingLeftLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Left") + ":", SwingConstants.RIGHT); UILabel paddingLeftLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Left") + ":", SwingConstants.RIGHT);
paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT));
UILabel paddingRightLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Right") + ":", SwingConstants.RIGHT); UILabel paddingRightLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Right") + ":", SwingConstants.RIGHT);
paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH / 2, LINE_COMPONENT_HEIGHT));
JPanel paddingPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ JPanel paddingPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
paddingLeftLabel, paddingLeftSpinner, paddingRightLabel,paddingRightSpinner new Component[]{ paddingTopLabel, paddingTopSpinner, paddingBottomLabel, paddingBottomSpinner},
}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); new Component[]{ paddingLeftLabel, paddingLeftSpinner, paddingRightLabel,paddingRightSpinner}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
paddingPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); paddingPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20));
return paddingPanel; return paddingPanel;
@ -164,6 +176,8 @@ public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane {
@Override @Override
protected void initDefaultConfig() { protected void initDefaultConfig() {
this.paddingTopSpinner.setValue(UniteStyle.DEFAULT_PADDING_TOP);
this.paddingBottomSpinner.setValue(UniteStyle.DEFAULT_PADDING_BOTTOM);
this.paddingLeftSpinner.setValue(UniteStyle.DEFAULT_PADDING_LEFT); this.paddingLeftSpinner.setValue(UniteStyle.DEFAULT_PADDING_LEFT);
this.paddingRightSpinner.setValue(UniteStyle.DEFAULT_PADDING_RIGHT); this.paddingRightSpinner.setValue(UniteStyle.DEFAULT_PADDING_RIGHT);
@ -191,6 +205,8 @@ public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane {
@Override @Override
public void populateSubStyle(MobileTemplateStyle ob) { public void populateSubStyle(MobileTemplateStyle ob) {
UniteStyle style = (UniteStyle) ob; UniteStyle style = (UniteStyle) ob;
this.paddingTopSpinner.setValue(style.getPaddingTop());
this.paddingBottomSpinner.setValue(style.getPaddingBottom());
this.paddingLeftSpinner.setValue(style.getPaddingLeft()); this.paddingLeftSpinner.setValue(style.getPaddingLeft());
this.paddingRightSpinner.setValue(style.getPaddingRight()); this.paddingRightSpinner.setValue(style.getPaddingRight());
@ -208,6 +224,8 @@ public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane {
@Override @Override
public MobileTemplateStyle updateSubStyle() { public MobileTemplateStyle updateSubStyle() {
UniteStyle style = new UniteStyle(); UniteStyle style = new UniteStyle();
style.setPaddingTop((int) this.paddingTopSpinner.getValue());
style.setPaddingBottom((int) this.paddingBottomSpinner.getValue());
style.setPaddingLeft((int) this.paddingLeftSpinner.getValue()); style.setPaddingLeft((int) this.paddingLeftSpinner.getValue());
style.setPaddingRight((int) this.paddingRightSpinner.getValue()); style.setPaddingRight((int) this.paddingRightSpinner.getValue());

28
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -19,11 +19,10 @@ import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Constructor;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Window; import java.awt.Window;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -45,6 +44,7 @@ public class DesignModuleFactory {
private Class<Widget> chartEditorClass; private Class<Widget> chartEditorClass;
private Class<MiddleChartComponent> chartComponentClass; private Class<MiddleChartComponent> chartComponentClass;
private Class<MiddleChartDialog> chartDialogClass; private Class<MiddleChartDialog> chartDialogClass;
private Class<MiddleChartDialog> autoChartDialogClass;
private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass; private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass;
private Class newFormAction; private Class newFormAction;
private Class formParaDesigner; private Class formParaDesigner;
@ -100,6 +100,10 @@ public class DesignModuleFactory {
instance.chartDialogClass = cd; instance.chartDialogClass = cd;
} }
public static void registerAutoChartDialogClass(Class autoChartDialogClass) {
instance.autoChartDialogClass = autoChartDialogClass;
}
public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) { public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) {
instance.chartPropertyPaneClass = p; instance.chartPropertyPaneClass = p;
} }
@ -205,6 +209,26 @@ public class DesignModuleFactory {
return null; return null;
} }
/**
* 初始化图表向导对话框, 调用静态方法showWindow, 参数window.
*
* @return 返回调出的图表自动推荐AutoChartDialog
*/
public static MiddleChartDialog getAutoChartDialog(Window window) {
try {
Constructor<MiddleChartDialog> c;
if (window instanceof Frame) {
c = instance.autoChartDialogClass.getConstructor(Frame.class);
} else {
c = instance.autoChartDialogClass.getConstructor(Dialog.class);
}
return c.newInstance(window);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/** /**
* kunsnat: 获取图表属性界面 * kunsnat: 获取图表属性界面
* *

17
designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java

@ -106,12 +106,8 @@ public class ParameterInputPane extends BasicPane {
contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane)); contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane));
//add editor to parameter hashtable. //add editor to parameter hashtable.
textF.getCurrentEditor().addChangeListener(new ChangeListener() { initTextListener(textF);
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
this.editorNameMap.put(textF, parameter.getName()); this.editorNameMap.put(textF, parameter.getName());
nameAddedList.add(parameter.getName()); nameAddedList.add(parameter.getName());
} }
@ -120,6 +116,15 @@ public class ParameterInputPane extends BasicPane {
flowTableLayoutHelper.adjustLabelWidth(); flowTableLayoutHelper.adjustLabelWidth();
} }
protected void initTextListener(ValueEditorPane textF) {
textF.getCurrentEditor().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
});
}
private Editor[] makeEditorByValue(Object pv) { private Editor[] makeEditorByValue(Object pv) {
Editor[] editors = {null}; Editor[] editors = {null};
if (pv instanceof Integer) { if (pv instanceof Integer) {

10
designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java

@ -2,7 +2,9 @@ package com.fr.design.present.dict;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.impl.DatabaseDictionary; import com.fr.data.impl.DatabaseDictionary;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
@ -23,7 +25,6 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -215,7 +216,12 @@ public class DatabaseDictPane extends FurtherBasicBeanPane<DatabaseDictionary> i
* *
*/ */
public void dbChange() { public void dbChange() {
TableData tableData = this.chooseTable.createSelectTableData(); TableData tableData = this.chooseTable.createSelectTableData(new ChoosePane.SelectSqlProcessor() {
@Override
public String createSelectSql(String schema, String tableName, Dialect dialect) {
return DataCoreUtils.createColumnSelectSQL(schema, tableName, dialect);
}
});
String[] columnNames = DesignTableDataManager.getColumnNamesByTableData(tableData).toArray(new String[0]); String[] columnNames = DesignTableDataManager.getColumnNamesByTableData(tableData).toArray(new String[0]);
ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames);
columnNameEditor1.addItemListener(itemListener); columnNameEditor1.addItemListener(itemListener);

68
designer-base/src/main/java/com/fr/design/ui/Assistant.java

@ -0,0 +1,68 @@
package com.fr.design.ui;
import com.fr.stable.StringUtils;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserContext;
import com.teamdev.jxbrowser.chromium.ProtocolService;
import com.teamdev.jxbrowser.chromium.URLResponse;
import javax.activation.MimetypesFileTypeMap;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-07
*/
public class Assistant {
public static URLResponse inputStream2Response(InputStream inputStream, String filePath) throws Exception {
URLResponse response = new URLResponse();
DataInputStream stream = new DataInputStream(inputStream);
byte[] data = new byte[stream.available()];
stream.readFully(data);
response.setData(data);
String mimeType = getMimeType(filePath);
response.getHeaders().setHeader("Content-Type", mimeType);
return response;
}
private static String getMimeType(String path) {
if (StringUtils.isBlank(path)) {
return "text/html";
}
if (path.endsWith(".html")) {
return "text/html";
}
if (path.endsWith(".css")) {
return "text/css";
}
if (path.endsWith(".js")) {
return "text/javascript";
}
if (path.endsWith(".svg")) {
return "image/svg+xml";
}
Path file = new File(path).toPath();
try {
return Files.probeContentType(file);
} catch (IOException e) {
return "text/html";
}
}
public static void setEmbProtocolHandler(Browser browser, EmbProtocolHandler handler) {
BrowserContext browserContext = browser.getContext();
ProtocolService protocolService = browserContext.getProtocolService();
// 支持读取jar包中文件的自定义协议————emb:/com/fr/design/images/bbs.png
protocolService.setProtocolHandler("emb", handler);
protocolService.setProtocolHandler("file", handler);
}
}

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

@ -0,0 +1,130 @@
package com.fr.design.ui;
import com.fr.base.TemplateUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.net.URLCodec;
import com.fr.third.org.apache.commons.io.FileUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
import com.teamdev.jxbrowser.chromium.ProtocolHandler;
import com.teamdev.jxbrowser.chromium.URLRequest;
import com.teamdev.jxbrowser.chromium.URLResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-07
*/
public class EmbProtocolHandler implements ProtocolHandler {
private AssembleComponent component;
private Map<String, String> map;
public EmbProtocolHandler() {
}
public EmbProtocolHandler(AssembleComponent component) {
this.component = component;
}
public EmbProtocolHandler(AssembleComponent component, Map<String, String> map) {
this.component = component;
this.map = map;
}
public EmbProtocolHandler(Map<String, String> map) {
this.map = map;
}
@Override
public URLResponse onRequest(URLRequest req) {
InputStream inputStream = null;
try {
String path = req.getURL();
if (path.startsWith("file:")) {
String url = new URLCodec().decode(path);
String filePath = TemplateUtils.renderParameter4Tpl(url, map);
File file = new File(URI.create(filePath).getPath());
inputStream = IOUtils.readResource(file.getAbsolutePath());
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
text = TemplateUtils.renderParameter4Tpl(text, map);
return Assistant.inputStream2Response(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), path);
} else if (path.startsWith("emb:dynamic")) {
URLResponse response = new URLResponse();
response.setData(htmlText(map).getBytes());
response.getHeaders().setHeader("Content-Type", "text/html");
return response;
} else {
int index = path.indexOf("=");
if (index > 0) {
path = path.substring(index + 1);
} else {
path = path.substring(4);
}
inputStream = IOUtils.readResource(path);
return Assistant.inputStream2Response(inputStream, path);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
return null;
}
private String htmlText(Map<String, String> map) {
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component);
StylePath[] stylePaths = pathGroup.toStylePathGroup();
StringBuilder styleText = new StringBuilder();
for (StylePath path : stylePaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
styleText.append("<link rel=\"stylesheet\" href=\"emb:");
styleText.append(path.toFilePath());
styleText.append("\"/>");
}
}
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString());
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup();
StringBuilder scriptText = new StringBuilder();
for (ScriptPath path : scriptPaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
scriptText.append("<script src=\"emb:");
scriptText.append(path.toFilePath());
scriptText.append("\"></script>");
}
}
result = result.replaceAll("##script##", scriptText.toString());
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
result = result.replaceAll("\\$\\{" + key + "}", value);
}
}
return result;
}
}

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

@ -7,18 +7,21 @@ import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.web.struct.AssembleComponent; import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.browser.Browser; import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.chromium.BrowserPreferences;
import com.teamdev.jxbrowser.engine.Engine; import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.engine.EngineOptions; import com.teamdev.jxbrowser.chromium.events.FinishLoadingEvent;
import com.teamdev.jxbrowser.engine.RenderingMode; import com.teamdev.jxbrowser.chromium.events.LoadAdapter;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.chromium.events.LoadListener;
import com.teamdev.jxbrowser.net.Network; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import com.teamdev.jxbrowser.view.swing.BrowserView; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map; import java.util.Map;
/** /**
@ -39,8 +42,9 @@ public class ModernUIPane<T> extends BasicPane {
} }
private void initialize() { private void initialize() {
setLayout(new BorderLayout());
if (browser == null) { if (browser == null) {
setLayout(new BorderLayout());
BrowserPreferences.setChromiumSwitches("--disable-google-traffic");
if (DesignerEnvManager.getEnvManager().isOpenDebug()) { if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
UIToolbar toolbar = new UIToolbar(); UIToolbar toolbar = new UIToolbar();
add(toolbar, BorderLayout.NORTH); add(toolbar, BorderLayout.NORTH);
@ -51,67 +55,75 @@ public class ModernUIPane<T> extends BasicPane {
UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window")); UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window"));
toolbar.add(closeButton); toolbar.add(closeButton);
openDebugButton.addActionListener(e -> showDebuggerDialog()); openDebugButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showDebuggerDialog();
}
});
reloadButton.addActionListener(e -> browser.navigation().reloadIgnoringCache()); reloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
browser.reloadIgnoringCache();
}
});
closeButton.addActionListener(e -> SwingUtilities.getWindowAncestor(ModernUIPane.this).setVisible(false)); closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.getWindowAncestor(ModernUIPane.this).setVisible(false);
}
});
BrowserPreferences.setChromiumSwitches("--remote-debugging-port=9222");
initializeBrowser(); initializeBrowser();
add(BrowserView.newInstance(browser), BorderLayout.CENTER); add(new BrowserView(browser), BorderLayout.CENTER);
} else { } else {
initializeBrowser(); initializeBrowser();
add(BrowserView.newInstance(browser), BorderLayout.CENTER); add(new BrowserView(browser), BorderLayout.CENTER);
} }
} }
} }
private void showDebuggerDialog() { private void showDebuggerDialog() {
JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this)); JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this));
Engine engine = Engine.newInstance( Browser debugger = new Browser();
EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED) BrowserView debuggerView = new BrowserView(debugger);
.addSwitch("--disable-google-traffic")
.remoteDebuggingPort(9222).build());
Browser debugger = engine.newBrowser();
BrowserView debuggerView = BrowserView.newInstance(debugger);
dialog.add(debuggerView, BorderLayout.CENTER); dialog.add(debuggerView, BorderLayout.CENTER);
dialog.setSize(new Dimension(800, 400)); dialog.setSize(new Dimension(800, 400));
GUICoreUtils.centerWindow(dialog); GUICoreUtils.centerWindow(dialog);
dialog.setVisible(true); dialog.setVisible(true);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
browser.devTools().remoteDebuggingUrl().ifPresent(url -> { debugger.loadURL(browser.getRemoteDebuggingURL());
debugger.navigation().loadUrl(url);
});
} }
private void initializeBrowser() { private void initializeBrowser() {
Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build()); browser = new Browser();
browser = engine.newBrowser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
browser.set(InjectJsCallback.class, params -> { browser.addScriptContextListener(new ScriptContextAdapter() {
params.frame().executeJavaScript(String.format(ModernUIConstants.SCRIPT_INIT_NAME_SPACE, namespace)); @Override
return InjectJsCallback.Response.proceed(); public void onScriptContextCreated(ScriptContextEvent event) {
event.getBrowser().executeJavaScript(String.format(ModernUIConstants.SCRIPT_INIT_NAME_SPACE, namespace));
}
}); });
} }
/** /**
* 转向一个新的地址相当于重新加载 * 转向一个新的地址相当于重新加载
*
* @param url 新的地址 * @param url 新的地址
*/ */
public void redirect(String url) { public void redirect(String url) {
browser.navigation().loadUrl(url); browser.loadURL(url);
} }
/** /**
* 转向一个新的地址相当于重新加载 * 转向一个新的地址相当于重新加载
*
* @param url 新的地址 * @param url 新的地址
* @param map 初始化参数 * @param map 初始化参数
*/ */
public void redirect(String url, Map<String, String> map) { public void redirect(String url, Map<String, String> map) {
Network network = browser.engine().network(); Assistant.setEmbProtocolHandler(browser, new EmbProtocolHandler(map));
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); browser.loadURL(url);
browser.navigation().loadUrl(url);
} }
@Override @Override
@ -121,18 +133,19 @@ public class ModernUIPane<T> extends BasicPane {
public void populate(final T t) { public void populate(final T t) {
browser.set(InjectJsCallback.class, params -> { browser.addScriptContextListener(new ScriptContextAdapter() {
JsObject ns = params.frame().executeJavaScript("window." + namespace); @Override
if (ns != null) { public void onScriptContextCreated(ScriptContextEvent event) {
ns.putProperty(variable, t); JSValue ns = event.getBrowser().executeJavaScriptAndReturnValue("window." + namespace);
ns.asObject().setProperty(variable, t);
} }
return InjectJsCallback.Response.proceed();
}); });
} }
public T update() { public T update() {
if (browser.mainFrame().isPresent()) { JSValue jsValue = browser.executeJavaScriptAndReturnValue("window." + namespace + "." + expression);
return browser.mainFrame().get().executeJavaScript("window." + namespace + "." + expression); if (jsValue.isObject()) {
return (T)jsValue.asJavaObject();
} }
return null; return null;
} }
@ -141,89 +154,79 @@ public class ModernUIPane<T> extends BasicPane {
private ModernUIPane<T> pane = new ModernUIPane<>(); private ModernUIPane<T> pane = new ModernUIPane<>();
public Builder<T> prepare(InjectJsCallback callback) { public Builder<T> prepare(ScriptContextListener contextListener) {
pane.browser.set(InjectJsCallback.class, callback); pane.browser.addScriptContextListener(contextListener);
return this;
}
public Builder<T> prepare(LoadListener loadListener) {
pane.browser.addLoadListener(loadListener);
return this; return this;
} }
/** /**
* 加载jar包中的资源 * 加载jar包中的资源
*
* @param path 资源路径 * @param path 资源路径
*/ */
public Builder<T> withEMB(final String path) { public Builder<T> withEMB(final String path) {
Network network = pane.browser.engine().network(); Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler());
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.browser.loadURL("emb:" + path);
pane.browser.navigation().loadUrl("emb:" + path);
return this; return this;
} }
/** /**
* 加载url指向的资源 * 加载url指向的资源
*
* @param url 文件的地址 * @param url 文件的地址
*/ */
public Builder<T> withURL(final String url) { public Builder<T> withURL(final String url) {
Network network = pane.browser.engine().network(); Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler());
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.browser.loadURL(url);
pane.browser.navigation().loadUrl(url);
return this; return this;
} }
/** /**
* 加载url指向的资源 * 加载url指向的资源
*
* @param url 文件的地址 * @param url 文件的地址
*/ */
public Builder<T> withURL(final String url, Map<String, String> map) { public Builder<T> withURL(final String url, Map<String, String> map) {
Network network = pane.browser.engine().network(); Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(map));
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); pane.browser.loadURL(url);
pane.browser.navigation().loadUrl(url);
return this; return this;
} }
/** /**
* 加载Atom组件 * 加载Atom组件
*
* @param component Atom组件 * @param component Atom组件
*/ */
public Builder<T> withComponent(AssembleComponent component) { public Builder<T> withComponent(AssembleComponent component) {
Network network = pane.browser.engine().network(); Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(component));
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component)); pane.browser.loadURL("emb:dynamic");
pane.browser.navigation().loadUrl("emb:dynamic");
return this; return this;
} }
/** /**
* 加载Atom组件 * 加载Atom组件
*
* @param component Atom组件 * @param component Atom组件
*/ */
public Builder<T> withComponent(AssembleComponent component, Map<String, String> map) { public Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
Network network = pane.browser.engine().network(); Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(component, map));
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component, map)); pane.browser.loadURL("emb:dynamic");
pane.browser.navigation().loadUrl("emb:dynamic");
return this; return this;
} }
/** /**
* 加载html文本内容 * 加载html文本内容
*
* @param html 要加载html文本内容 * @param html 要加载html文本内容
*/ */
public Builder<T> withHTML(String html) { public Builder<T> withHTML(String html) {
Network network = pane.browser.engine().network(); Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler());
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.browser.loadHTML(html);
pane.browser.mainFrame().ifPresent(frame -> {
frame.loadHtml(html);
});
return this; return this;
} }
/** /**
* 设置该前端页面做数据交换所使用的对象 * 设置该前端页面做数据交换所使用的对象
*
* @param namespace 对象名 * @param namespace 对象名
*/ */
public Builder<T> namespace(String namespace) { public Builder<T> namespace(String namespace) {
@ -233,7 +236,6 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* java端往js端传数据时使用的变量名字 * java端往js端传数据时使用的变量名字
*
* @param name 变量的名字 * @param name 变量的名字
*/ */
public Builder<T> variable(String name) { public Builder<T> variable(String name) {
@ -243,7 +245,6 @@ public class ModernUIPane<T> extends BasicPane {
/** /**
* js端往java端传数据时执行的函数表达式 * js端往java端传数据时执行的函数表达式
*
* @param expression 函数表达式 * @param expression 函数表达式
*/ */
public Builder<T> expression(String expression) { public Builder<T> expression(String expression) {

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

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

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

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

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

@ -6,7 +6,6 @@ import com.fr.config.ServerPreferenceConfig;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.bridge.exec.JSBridge; import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.bridge.exec.JSCallback; import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.bridge.exec.JSExecutor;
import com.fr.design.extra.PluginOperateUtils; import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.extra.PluginUtils; import com.fr.design.extra.PluginUtils;
import com.fr.design.extra.exe.GetInstalledPluginsExecutor; import com.fr.design.extra.exe.GetInstalledPluginsExecutor;
@ -29,8 +28,10 @@ import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.teamdev.jxbrowser.js.JsAccessible; import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.chromium.JSArray;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
@ -51,44 +52,41 @@ import java.util.concurrent.RunnableFuture;
*/ */
public class UpmBridge { public class UpmBridge {
public static UpmBridge getBridge() { public static UpmBridge getBridge(Browser browser) {
return new UpmBridge(); return new UpmBridge(browser);
} }
private JSObject window;
private UpmBridge() { private UpmBridge(Browser browser) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
} }
/** /**
* 更新插件管理中心资源文件这个方法仅仅是为了语义上的作用更新 * 更新插件管理中心资源文件这个方法仅仅是为了语义上的作用更新
*
* @param callback 安装完成后的回调函数 * @param callback 安装完成后的回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void update(final JSFunction callback) {
public void update(final JsObject callback) { callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
try { try {
UpmResourceLoader.INSTANCE.download(); UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install(); UpmResourceLoader.INSTANCE.install();
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success"));
EventDispatcher.fire(DownloadEvent.UPDATE, "success"); EventDispatcher.fire(DownloadEvent.UPDATE, "success");
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error"));
} }
} }
/** /**
* 下载并安装插件管理中心的资源文件 * 下载并安装插件管理中心的资源文件
*
* @param callback 安装完成后的回调函数 * @param callback 安装完成后的回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void startDownload(final JSFunction callback) {
public void startDownload(final JsObject callback) { callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, "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 {
@ -101,10 +99,10 @@ public class UpmBridge {
protected void done() { protected void done() {
try { try {
get(); get();
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success"));
EventDispatcher.fire(DownloadEvent.SUCCESS, "success"); EventDispatcher.fire(DownloadEvent.SUCCESS, "success");
} catch (Exception e) { } catch (Exception e) {
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error"));
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
EventDispatcher.fire(DownloadEvent.ERROR, "error"); EventDispatcher.fire(DownloadEvent.ERROR, "error");
} }
@ -114,44 +112,37 @@ public class UpmBridge {
/** /**
* 获取upm的版本信息 * 获取upm的版本信息
*
* @return 版本信息 * @return 版本信息
*/ */
@JSBridge @JSBridge
@JsAccessible
public String getVersion() { public String getVersion() {
return ServerPreferenceConfig.getInstance().getOptimizedUPMVersion(); return ServerPreferenceConfig.getInstance().getOptimizedUPMVersion();
} }
@JSBridge @JSBridge
@JsAccessible
public String i18nText(String key) { public String i18nText(String key) {
return Toolkit.i18nText(key); return Toolkit.i18nText(key);
} }
@JSBridge @JSBridge
@JsAccessible
public void closeWindow() { public void closeWindow() {
UpmFinder.closeWindow(); UpmFinder.closeWindow();
} }
@JSBridge @JSBridge
@JsAccessible
public boolean isDesigner() { public boolean isDesigner() {
return true; return true;
} }
@JSBridge @JSBridge
@JsAccessible public void getPackInfo(final JSFunction callback) {
public void getPackInfo(final JsObject callback) { callback.invoke(window, StringUtils.EMPTY);
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, StringUtils.EMPTY);
} }
@JSBridge @JSBridge
@JsAccessible public void getPluginPrefix(final JSFunction callback) {
public void getPluginPrefix(final JsObject callback) { UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginPrefixExecutor());
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new GetPluginPrefixExecutor());
task.execute(); task.execute();
} }
@ -161,9 +152,8 @@ public class UpmBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void getPluginCategories(final JSFunction callback) {
public void getPluginCategories(final JsObject callback) { UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginCategoriesExecutor());
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new GetPluginCategoriesExecutor());
task.execute(); task.execute();
} }
@ -174,9 +164,8 @@ public class UpmBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void getPluginFromStoreNew(String info, final JSFunction callback) {
public void getPluginFromStoreNew(String info, final JsObject callback) { UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginFromStoreExecutor(new JSONObject(info)));
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new GetPluginFromStoreExecutor(new JSONObject(info)));
task.execute(); task.execute();
} }
@ -184,9 +173,8 @@ public class UpmBridge {
* 已安装插件检查更新 * 已安装插件检查更新
*/ */
@JSBridge @JSBridge
@JsAccessible public void readUpdateOnline(final JSFunction callback) {
public void readUpdateOnline(final JsObject callback) { UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new ReadUpdateOnlineExecutor());
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new ReadUpdateOnlineExecutor());
task.execute(); task.execute();
} }
@ -194,9 +182,8 @@ public class UpmBridge {
* 获取已经安装的插件的数组 * 获取已经安装的插件的数组
*/ */
@JSBridge @JSBridge
@JsAccessible public void getInstalledPlugins(final JSFunction callback) {
public void getInstalledPlugins(final JsObject callback) { UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetInstalledPluginsExecutor());
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new GetInstalledPluginsExecutor());
task.execute(); task.execute();
} }
@ -206,24 +193,18 @@ public class UpmBridge {
* @param pluginIDs 插件集合 * @param pluginIDs 插件集合
*/ */
@JSBridge @JSBridge
@JsAccessible public void updatePluginOnline(Object pluginIDs, final JSFunction callback) {
public void updatePluginOnline(JsObject pluginIDs, final JsObject callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
List<PluginMarker> pluginMarkerList = new ArrayList<>(); List<PluginMarker> pluginMarkerList = new ArrayList<>();
for (String key : pluginIDs.propertyNames()) { if (pluginIDs instanceof String) {
pluginIDs.property(key).ifPresent(v -> { pluginMarkerList.add(PluginUtils.createPluginMarker(pluginIDs.toString()));
pluginMarkerList.add(PluginUtils.createPluginMarker(GeneralUtils.objectToString(v))); } else if (pluginIDs instanceof JSArray) {
}); JSArray pluginInfos = (JSArray) pluginIDs;
for (int i = 0, len = pluginInfos.length(); i < len; i++) {
String value = pluginInfos.get(i).asString().getValue();
pluginMarkerList.add(PluginUtils.createPluginMarker(value));
} }
PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback);
} }
@JSBridge
@JsAccessible
public void updatePluginOnline(String pluginID, final JsObject callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
List<PluginMarker> pluginMarkerList = new ArrayList<>();
pluginMarkerList.add(PluginUtils.createPluginMarker(pluginID));
PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback); PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback);
} }
@ -233,9 +214,8 @@ public class UpmBridge {
* @param keyword 关键字 * @param keyword 关键字
*/ */
@JSBridge @JSBridge
@JsAccessible public void searchPlugin(String keyword, final JSFunction callback) {
public void searchPlugin(String keyword, final JsObject callback) { UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new SearchOnlineExecutor(keyword));
UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new SearchOnlineExecutor(keyword));
worker.execute(); worker.execute();
} }
@ -245,9 +225,8 @@ public class UpmBridge {
* @param filePath 插件包的路径 * @param filePath 插件包的路径
*/ */
@JSBridge @JSBridge
@JsAccessible public void installPluginFromDisk(final String filePath, final JSFunction callback) {
public void installPluginFromDisk(final String filePath, final JsObject callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
File file = new File(filePath); File file = new File(filePath);
PluginOperateUtils.installPluginFromDisk(file, jsCallback); PluginOperateUtils.installPluginFromDisk(file, jsCallback);
} }
@ -258,9 +237,8 @@ public class UpmBridge {
* @param pluginInfo 插件信息 * @param pluginInfo 插件信息
*/ */
@JSBridge @JSBridge
@JsAccessible public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSFunction callback) {
public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JsObject callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback);
} }
@ -271,9 +249,8 @@ public class UpmBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void installPluginOnline(final String pluginInfo, final JSFunction callback) {
public void installPluginOnline(final String pluginInfo, final JsObject callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback);
} }
@ -283,10 +260,8 @@ public class UpmBridge {
* *
* @param filePath 插件包的路径 * @param filePath 插件包的路径
*/ */
@JSBridge public void updatePluginFromDisk(String filePath, final JSFunction callback) {
@JsAccessible JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
public void updatePluginFromDisk(String filePath, final JsObject callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
File file = new File(filePath); File file = new File(filePath);
PluginOperateUtils.updatePluginFromDisk(file, jsCallback); PluginOperateUtils.updatePluginFromDisk(file, jsCallback);
} }
@ -297,9 +272,8 @@ public class UpmBridge {
* @param pluginID 插件ID * @param pluginID 插件ID
*/ */
@JSBridge @JSBridge
@JsAccessible public void setPluginActive(String pluginID, final JSFunction callback) {
public void setPluginActive(String pluginID, final JsObject callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
PluginOperateUtils.setPluginActive(pluginID, jsCallback); PluginOperateUtils.setPluginActive(pluginID, jsCallback);
} }
@ -309,7 +283,6 @@ public class UpmBridge {
* @return 选择的文件的路径 * @return 选择的文件的路径
*/ */
@JSBridge @JSBridge
@JsAccessible
public String showFileChooser() { public String showFileChooser() {
return showFileChooserWithFilter(StringUtils.EMPTY, StringUtils.EMPTY); return showFileChooserWithFilter(StringUtils.EMPTY, StringUtils.EMPTY);
} }
@ -323,7 +296,6 @@ public class UpmBridge {
* 这里换用JFileChooser会卡死,不知道为什么 * 这里换用JFileChooser会卡死,不知道为什么
*/ */
@JSBridge @JSBridge
@JsAccessible
public String showFileChooserWithFilter(final String des, final String filter) { public String showFileChooserWithFilter(final String des, final String filter) {
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() { RunnableFuture<String> future = new FutureTask<>(new Callable<String>() {
@Override @Override
@ -359,49 +331,19 @@ public class UpmBridge {
* @return 选择的文件的路径 * @return 选择的文件的路径
*/ */
@JSBridge @JSBridge
@JsAccessible public String showFileChooserWithFilters(final String des, final Object args) {
public String showFileChooserWithFilters(final String des, final String args) { RunnableFuture<String> future = new FutureTask<>(new Callable<String>() {
RunnableFuture<String> future = new FutureTask<>(() -> { @Override
public String call() {
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = new JFileChooser();
List<String> filterList = new ArrayList<>(); List<String> filterList = new ArrayList<>();
filterList.add(args); if (args instanceof String) {
String[] filters = filterList.toArray(new String[0]); filterList.add(GeneralUtils.objectToString(args));
if (ArrayUtils.isNotEmpty(filters)) { } else if (args instanceof JSArray) {
FileNameExtensionFilter filter = new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filters)); JSArray array = (JSArray)args;
fileChooser.setFileFilter(filter); for (int i = 0, len = array.length(); i < len; i ++) {
filterList.add(array.get(i).getStringValue());
} }
int result = fileChooser.showOpenDialog(UpmFinder.getDialog());
if (result == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile().getAbsolutePath();
}
return null;
});
SwingUtilities.invokeLater(future);
try {
return future.get();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/**
* 选择文件对话框
*
* @param des 过滤文件描述
* @param args 文件的后缀
* @return 选择的文件的路径
*/
@JSBridge
@JsAccessible
public String showFileChooserWithFilters(final String des, final JsObject args) {
RunnableFuture<String> future = new FutureTask<>(() -> {
JFileChooser fileChooser = new JFileChooser();
List<String> filterList = new ArrayList<>();
for (String key : args.propertyNames()) {
args.property(key).ifPresent(v -> {
filterList.add(GeneralUtils.objectToString(v));
});
} }
String[] filters = filterList.toArray(new String[0]); String[] filters = filterList.toArray(new String[0]);
if (ArrayUtils.isNotEmpty(filters)) { if (ArrayUtils.isNotEmpty(filters)) {
@ -413,6 +355,7 @@ public class UpmBridge {
return fileChooser.getSelectedFile().getAbsolutePath(); return fileChooser.getSelectedFile().getAbsolutePath();
} }
return null; return null;
}
}); });
SwingUtilities.invokeLater(future); SwingUtilities.invokeLater(future);
try { try {
@ -429,8 +372,7 @@ public class UpmBridge {
* 获取系统登录的用户名 * 获取系统登录的用户名
*/ */
@JSBridge @JSBridge
@JsAccessible public String getLoginInfo(final JSFunction callback) {
public String getLoginInfo(final JsObject callback) {
registerLoginInfo(callback); registerLoginInfo(callback);
return MarketConfig.getInstance().getBbsUsername(); return MarketConfig.getInstance().getBbsUsername();
} }
@ -441,9 +383,8 @@ public class UpmBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void registerLoginInfo(final JSFunction callback) {
public void registerLoginInfo(final JsObject callback) { JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(callback));
String username = MarketConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) { if (StringUtils.isEmpty(username)) {
jsCallback.execute(StringUtils.EMPTY); jsCallback.execute(StringUtils.EMPTY);
@ -463,16 +404,14 @@ public class UpmBridge {
* @param callback 回调函数 * @param callback 回调函数
*/ */
@JSBridge @JSBridge
@JsAccessible public void defaultLogin(String username, String password, final JSFunction callback) {
public void defaultLogin(String username, String password, final JsObject callback) { UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new PluginLoginExecutor(username, password));
UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(callback)), new PluginLoginExecutor(username, password));
worker.execute(); worker.execute();
} }
/** /**
* 清除用户信息 * 清除用户信息
*/ */
@JsAccessible
public void clearUserInfo() { public void clearUserInfo() {
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
FinePassportManager.getInstance().logout(); FinePassportManager.getInstance().logout();
@ -483,7 +422,6 @@ public class UpmBridge {
* 打开论坛消息界面 * 打开论坛消息界面
*/ */
@JSBridge @JSBridge
@JsAccessible
public void getPriviteMessage() { public void getPriviteMessage() {
try { try {
String loginUrl = CloudCenter.getInstance().acquireUrlByKind("bbs.default"); String loginUrl = CloudCenter.getInstance().acquireUrlByKind("bbs.default");
@ -497,7 +435,6 @@ public class UpmBridge {
* 忘记密码 * 忘记密码
*/ */
@JSBridge @JSBridge
@JsAccessible
public void forgetHref() { public void forgetHref() {
try { try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset"))); Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset")));
@ -510,7 +447,6 @@ public class UpmBridge {
* 立即注册 * 立即注册
*/ */
@JSBridge @JSBridge
@JsAccessible
public void registerHref() { public void registerHref() {
try { try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.register"))); Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.register")));
@ -521,11 +457,9 @@ public class UpmBridge {
/** /**
* 使用系统浏览器打开网页 * 使用系统浏览器打开网页
*
* @param url 要打开的网页 * @param url 要打开的网页
*/ */
@JSBridge @JSBridge
@JsAccessible
public void openShopUrlAtWebBrowser(String url) { public void openShopUrlAtWebBrowser(String url) {
if (Desktop.isDesktopSupported()) { if (Desktop.isDesktopSupported()) {
try { try {

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

@ -58,7 +58,7 @@ public class UpmFinder {
public static void showUPMDialog() { public static void showUPMDialog() {
boolean flag = true; boolean flag = true;
try { try {
Class.forName("com.teamdev.jxbrowser.browser.Browser"); Class.forName("com.teamdev.jxbrowser.chromium.Browser");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
flag = false; flag = false;
} }
@ -88,7 +88,7 @@ public class UpmFinder {
dialog.setVisible(true); dialog.setVisible(true);
} }
} else { } else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit(); dialog.setAutoUpdateAfterInit();
dialog.showDialog(); dialog.showDialog();

15
designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java

@ -6,8 +6,9 @@ import com.fr.design.upm.event.DownloadEvent;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.*; import java.awt.*;
@ -31,10 +32,12 @@ public class UpmShowPane extends BasicPane {
// 先屏蔽掉这个判断,后续可能修改交互 // 先屏蔽掉这个判断,后续可能修改交互
// if (UpmFinder.checkUPMResourcesExist()) { // if (UpmFinder.checkUPMResourcesExist()) {
modernUIPane = new ModernUIPane.Builder<>() modernUIPane = new ModernUIPane.Builder<>()
.prepare(params -> { .prepare(new ScriptContextAdapter() {
JsObject window = params.frame().executeJavaScript("window"); @Override
window.putProperty("PluginHelper", UpmBridge.getBridge()); public void onScriptContextCreated(ScriptContextEvent event) {
return InjectJsCallback.Response.proceed(); JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
}) })
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build(); .build();

15
designer-base/src/main/java/com/fr/design/upm/exec/UpmBrowserExecutor.java

@ -1,7 +1,8 @@
package com.fr.design.upm.exec; package com.fr.design.upm.exec;
import com.fr.design.bridge.exec.JSExecutor; import com.fr.design.bridge.exec.JSExecutor;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
/** /**
* @author richie * @author richie
@ -10,18 +11,20 @@ import com.teamdev.jxbrowser.js.JsObject;
*/ */
public class UpmBrowserExecutor implements JSExecutor { public class UpmBrowserExecutor implements JSExecutor {
public static UpmBrowserExecutor create(JsObject callback) { public static UpmBrowserExecutor create(JSObject window, JSFunction callback) {
return new UpmBrowserExecutor(callback); return new UpmBrowserExecutor(window, callback);
} }
private JsObject callback; private JSObject window;
private JSFunction callback;
private UpmBrowserExecutor(JsObject callback) { private UpmBrowserExecutor(JSObject window, JSFunction callback) {
this.window = window;
this.callback = callback; this.callback = callback;
} }
@Override @Override
public void executor(String newValue) { public void executor(String newValue) {
callback.call(JSExecutor.CALLBACK_FUNCTION_NAME, newValue); callback.invoke(window, newValue);
} }
} }

6
designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

@ -398,9 +398,11 @@ public final class GUICoreUtils {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP); screen.setSize(screen.getSize().width, screen.height - HEIGHT_GAP);
int showOnScreenX = Math.min(screen.width, parentComponent.getLocationOnScreen().x + parentComponent.getWidth());
// peter:调整X的高度. // peter:调整X的高度.
if (point.x + size.width > screen.width && size.width < screen.width) { if (point.x + size.width > showOnScreenX && size.width < showOnScreenX) {
x += (screen.width - point.x - size.width); x += (showOnScreenX - point.x - size.width);
} }
// peter:调整y高度. // peter:调整y高度.

68
designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java

@ -36,6 +36,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils; import com.fr.general.DateUtils;
import com.fr.general.data.Condition; import com.fr.general.data.Condition;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.ColumnRowGroup; import com.fr.stable.ColumnRowGroup;
import com.fr.write.DBManipulation; import com.fr.write.DBManipulation;
@ -47,14 +48,31 @@ import com.fr.write.config.InsertConfig;
import com.fr.write.config.IntelliDMLConfig; import com.fr.write.config.IntelliDMLConfig;
import com.fr.write.config.UpdateConfig; import com.fr.write.config.UpdateConfig;
import javax.swing.*; import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
@ -911,6 +929,11 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return ComparatorUtils.equals(this.name, ((ColumnName)obj).name); return ComparatorUtils.equals(this.name, ((ColumnName)obj).name);
} }
@Override
protected ColumnName clone() throws CloneNotSupportedException {
return new ColumnName(name);
}
} }
public static class ColumnValue { public static class ColumnValue {
@ -931,6 +954,11 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj); return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj);
} }
@Override
protected ColumnValue clone() throws CloneNotSupportedException {
return new ColumnValue(obj);
}
} }
protected static class KeyColumnNameValueTable extends JTable { protected static class KeyColumnNameValueTable extends JTable {
@ -941,7 +969,14 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
public KeyColumnTableModel getTableModel4SmartAddCell() { public KeyColumnTableModel getTableModel4SmartAddCell() {
return new KeyColumnValueTableModel((KeyColumnTableModel)this.getModel()); KeyColumnTableModel clonedTableModel = null;
try {
//智能添加的时候修改clone的配置,不修改原配置,点击确认后覆盖原配置
clonedTableModel = ((KeyColumnValueTableModel) this.getModel()).clone();
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return new KeyColumnValueTableModel(clonedTableModel);
} }
} }
@ -953,7 +988,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE}; public static final String[] COLUMN_NAMES = new String[]{RAW_KEY, COLUMN, VALUE};
protected java.util.List<KeyColumnNameValue> keyColumnNameValueList = new ArrayList<KeyColumnNameValue>(); protected List<KeyColumnNameValue> keyColumnNameValueList = new ArrayList<>();
public KeyColumnTableModel(KeyColumnTableModel model) { public KeyColumnTableModel(KeyColumnTableModel model) {
if (model != null) { if (model != null) {
@ -988,9 +1023,16 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
public void removeAllKeyColumnNameValue() { public void removeAllKeyColumnNameValue() {
this.keyColumnNameValueList.clear(); this.keyColumnNameValueList.clear();
} }
public void refreshNameValueList(KeyColumnTableModel model) {
if (model != null) {
this.keyColumnNameValueList.clear();
this.keyColumnNameValueList.addAll(model.keyColumnNameValueList);
}
}
} }
protected static class KeyColumnValueTableModel extends KeyColumnTableModel { protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable{
public KeyColumnValueTableModel(KeyColumnTableModel model) { public KeyColumnValueTableModel(KeyColumnTableModel model) {
super(model); super(model);
@ -1037,6 +1079,16 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
public boolean isCellEditable(int row, int col) { public boolean isCellEditable(int row, int col) {
return true; return true;
} }
@Override
protected KeyColumnValueTableModel clone() throws CloneNotSupportedException {
KeyColumnValueTableModel cloned = (KeyColumnValueTableModel) super.clone();
cloned.keyColumnNameValueList = new ArrayList<>();
for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) {
cloned.keyColumnNameValueList.add(keyColumnNameValue.clone());
}
return cloned;
}
} }
@ -1054,11 +1106,17 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
/** /**
* 字符串 * 字符串
*
* @return 字符串z * @return 字符串z
*/ */
public String toString() { public String toString() {
return (isKey ? "* " : "") + cn + ":" + cv; return (isKey ? "* " : "") + cn + ":" + cv;
} }
@Override
protected KeyColumnNameValue clone() throws CloneNotSupportedException {
return new KeyColumnNameValue(isKey, cn.clone(), cv.clone(), false);
}
} }
/* /*

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

@ -96,6 +96,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
* 密码 * 密码
*/ */
private UIPassWordField passwordInput = new UIPassWordField(); private UIPassWordField passwordInput = new UIPassWordField();
/**
* 是否记住密码
*/
private UICheckBox rememberPwdCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Env_Remember_Password"));
/** /**
* https证书路径 * https证书路径
*/ */
@ -212,7 +216,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
updateHttpsConfigPanel(); updateHttpsConfigPanel();
remoteWorkspaceURL.setHttps(isHttps); remoteWorkspaceURL.setHttps(isHttps);
// reset下url,将勾选状态是否htpps加到url里 // reset下url,将勾选状态是否https加到url里
remoteWorkspaceURL.resetUrl(); remoteWorkspaceURL.resetUrl();
fillRemoteEnvURLField(); fillRemoteEnvURLField();
@ -286,6 +290,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
contentPanel.add(configPanel, BorderLayout.NORTH); contentPanel.add(configPanel, BorderLayout.NORTH);
contentPanel.add(accountPanel, BorderLayout.CENTER); contentPanel.add(accountPanel, BorderLayout.CENTER);
contentPanel.add(packRememberPwdConfigPanel(), BorderLayout.SOUTH);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(contentPanel, BorderLayout.NORTH); panel.add(contentPanel, BorderLayout.NORTH);
panel.add(testPanel, BorderLayout.CENTER); panel.add(testPanel, BorderLayout.CENTER);
@ -306,15 +311,18 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY); String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY); String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY);
String certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY); String certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY);
boolean rememberPwd = fromNullable(connection.isRememberPwd()).or(true);
this.usernameInput.setText(username); this.usernameInput.setText(username);
this.passwordInput.setText(pwd); this.passwordInput.setText(pwd);
this.certPathInput.setText(certPath); this.certPathInput.setText(certPath);
this.certSecretKeyInput.setText(certSecretKey); this.certSecretKeyInput.setText(certSecretKey);
this.rememberPwdCheckbox.setSelected(rememberPwd);
} else { } else {
this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL(); this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL();
this.usernameInput.setText(StringUtils.EMPTY); this.usernameInput.setText(StringUtils.EMPTY);
this.passwordInput.setText(StringUtils.EMPTY); this.passwordInput.setText(StringUtils.EMPTY);
this.rememberPwdCheckbox.setSelected(true);
} }
fillRemoteEnvURLField(); fillRemoteEnvURLField();
@ -333,6 +341,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String url = this.remoteWorkspaceURL.getURL(); String url = this.remoteWorkspaceURL.getURL();
String username = this.usernameInput.getText(); String username = this.usernameInput.getText();
String password = new String(this.passwordInput.getPassword()); String password = new String(this.passwordInput.getPassword());
boolean rememberPwd = this.rememberPwdCheckbox.isSelected();
DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG);
if (envProcessor != null) { if (envProcessor != null) {
url = envProcessor.changeEnvPathBeforeConnect(username, password, url); url = envProcessor.changeEnvPathBeforeConnect(username, password, url);
@ -342,7 +351,8 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
username, username,
password, password,
this.certPathInput.getText(), this.certPathInput.getText(),
new String(this.certSecretKeyInput.getPassword())); new String(this.certSecretKeyInput.getPassword()),
rememberPwd);
return RemoteDesignerWorkspaceInfo.create(connection); return RemoteDesignerWorkspaceInfo.create(connection);
} }
@ -522,6 +532,20 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
accountPanel.add(content, BorderLayout.CENTER); accountPanel.add(content, BorderLayout.CENTER);
} }
private JPanel packRememberPwdConfigPanel() {
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{rememberPwdCheckbox}
},
new double[]{PREFERRED},
new double[]{PREFERRED},
5,
10
);
TableLayoutHelper.modifyTableLayoutIndexHGap(panel, 0, 50);
return panel;
}
private JPanel createHttpsCertFileInputPanel() { private JPanel createHttpsCertFileInputPanel() {
JPanel inputPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel inputPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();

1
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -73,6 +73,7 @@ public class FineEmbedServerActivator extends Activator {
//覆盖tomcat的WebAppClassLoader //覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader()); context.setLoader(new FRTomcatLoader());
//直接指定initializer,tomcat就不用再扫描一遍了 //直接指定initializer,tomcat就不用再扫描一遍了
SpringServletContainerInitializer initializer = new SpringServletContainerInitializer(); SpringServletContainerInitializer initializer = new SpringServletContainerInitializer();
Set<Class<?>> classes = new HashSet<Class<?>>(); Set<Class<?>> classes = new HashSet<Class<?>>();

BIN
designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

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

@ -2,7 +2,10 @@ package com.fr.design;
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.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.invoke.Reflect;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import org.easymock.EasyMock; import org.easymock.EasyMock;
@ -19,7 +22,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
* @Description: * @Description:
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class}) @PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class, DesignerEnvManager.class})
public class EnvChangeEntranceTest { public class EnvChangeEntranceTest {
@Test @Test
@ -55,4 +58,46 @@ public class EnvChangeEntranceTest {
} }
} }
@Test
public void testUpdateNotRememberPwdEnv() {
DesignerEnvManager manager = new DesignerEnvManager();
PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes();
PowerMock.replayAll();
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false)));
manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path"));
Reflect.on(entrance).call("updateNotRememberPwdEnv");
Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection());
Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection());
Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name");
Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path");
PowerMock.verifyAll();
}
@Test
public void testIsNotRememberPwd() {
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true));
DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false));
DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path");
DesignerWorkspaceInfo info4 = null;
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info1).get());
Assert.assertTrue((boolean) Reflect.on(entrance).call("isNotRememberPwd", info2).get());
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info3).get());
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info4).get());
}
} }

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

@ -0,0 +1,25 @@
package com.fr.design.env;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/7/15
*/
public class RemoteDesignerWorkspaceInfoTest extends TestCase {
public void testCheckValid() {
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 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));
Assert.assertFalse(workspaceInfo0.checkValid());
Assert.assertFalse(workspaceInfo1.checkValid());
Assert.assertFalse(workspaceInfo2.checkValid());
Assert.assertFalse(workspaceInfo3.checkValid());
}
}

3
designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java vendored

@ -38,7 +38,7 @@ public class RemoteWorkspaceTest {
EasyMock.replay(workspace, operator); EasyMock.replay(workspace, operator);
PowerMock.replayAll(); PowerMock.replayAll();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey"); WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey", true);
RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info); RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info);
@ -51,4 +51,5 @@ public class RemoteWorkspaceTest {
} }
} }

39
designer-base/src/test/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePaneTest.java

@ -0,0 +1,39 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.UniteStyle;
import com.fr.invoke.Reflect;
import junit.framework.TestCase;
import org.junit.Test;
import java.awt.*;
public class UniteStyleDefinePaneTest extends TestCase {
@Test
public void testDefaultConfig() {
UniteStyleDefinePane definePane = new UniteStyleDefinePane(new WCardTagLayout());
Reflect.on(definePane).call("initDefaultConfig");
double paddingTop = Reflect.on(definePane).field("paddingTopSpinner").call("getValue").get();
assertEquals((int)paddingTop, UniteStyle.DEFAULT_PADDING_TOP);
double paddingBottom = Reflect.on(definePane).field("paddingBottomSpinner").call("getValue").get();
assertEquals((int)paddingBottom, UniteStyle.DEFAULT_PADDING_BOTTOM);
double paddingLeft = Reflect.on(definePane).field("paddingLeftSpinner").call("getValue").get();
assertEquals((int)paddingLeft, UniteStyle.DEFAULT_PADDING_LEFT);
double paddingRight = Reflect.on(definePane).field("paddingRightSpinner").call("getValue").get();
assertEquals((int)paddingRight, UniteStyle.DEFAULT_PADDING_RIGHT);
Color initialBackgroundColor = Reflect.on(definePane).field("initialBackgroundColorBox").call("getSelectObject").get();
assertEquals(initialBackgroundColor, UniteStyle.DEFAULT_INITIAL_BACKGROUND_COLOR);
Color selectedBackgroundColor = Reflect.on(definePane).field("selectedBackgroundColorBox").call("getSelectObject").get();
assertEquals(selectedBackgroundColor, UniteStyle.DEFAULT_SELECTED_BACKGROUND_COLOR);
int lineStyle = Reflect.on(definePane).field("borderWidthComboBox").call("getSelectedLineStyle").get();
assertEquals(lineStyle, UniteStyle.DEFAULT_BORDER_LINE.lineStyle);
Color borderColor = Reflect.on(definePane).field("borderColorBox").call("getSelectObject").get();
assertEquals(borderColor, UniteStyle.DEFAULT_BORDER_LINE.color);
double borderRadius = Reflect.on(definePane).field("borderRadiusSpinner").call("getValue").get();
assertEquals((int)borderRadius, UniteStyle.DEFAULT_BORDER_RADIUS);
}
}

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

@ -104,6 +104,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.awt.event.ActionListener;
import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY; 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.DEPRECATED_CHART_PRIORITY;
@ -164,6 +165,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length];
int index = 0; int index = 0;
for (String chartID : chartIDs) { for (String chartID : chartIDs) {
ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) { if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) {
@ -258,17 +260,21 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
* *
* @param paneList pane容器 * @param paneList pane容器
*/ */
public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends ChartProvider>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane) { public void addPlotTypePaneList(List<FurtherBasicBeanPane<? extends ChartProvider>> paneList,
Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) {
List<Integer> priorityList = getPriorityInOrder(); List<Integer> priorityList = getPriorityInOrder();
for (Integer aPriorityList : priorityList) { for (Integer aPriorityList : priorityList) {
String priority = String.valueOf(aPriorityList); String priority = String.valueOf(aPriorityList);
addPlotTypePaneList(priority, paneList, allChartTypePane); addPlotTypePaneList(priority, paneList, allChartTypePane, autoButtonListener);
} }
} }
public void addPlotTypePaneList(String priority, List<FurtherBasicBeanPane<? extends ChartProvider>> paneList, Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane) { 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)) { if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) {
@ -285,6 +291,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
continue; continue;
} }
pane.reLayout(plotID); pane.reLayout(plotID);
pane.registerButtonListener(autoButtonListener);
paneList.add(pane); paneList.add(pane);
if (allChartTypePane.get(priority) == null) { if (allChartTypePane.get(priority) == null) {

90
designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java

@ -0,0 +1,90 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.TwoTuple;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartDialog extends ChartDialog {
private AutoChartTypePane autoChartTypePane;
public AutoChartDialog(Frame owner) {
super(owner);
}
public AutoChartDialog(Dialog owner) {
super(owner);
}
protected Component initCenterPane() {
autoChartTypePane = new AutoChartTypePane();
getOk().setEnabled(false);
autoChartTypePane.registsListAction(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
getOk().setEnabled(((JList) e.getSource()).getSelectedIndex() >= 0);
}
});
return autoChartTypePane;
}
protected ActionListener getActionListener(final String createTime) {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
ChartCollection chartCollection = (ChartCollection) getChartCollection();
autoChartTypePane.update(chartCollection, createTime);
if (chartCollection.getChartCount() > 0) {
doOK();
} else {
doCancel();
}
}
};
}
protected String getDialogTitle() {
return Toolkit.i18nText("Fine-Design_Chart_Auto_Recommended_Chart");
}
/**
* 更新新建的图表 ChartCollection
*/
public void populate(BaseChartCollection cc) {
super.populate(cc);
ChartCollection chartCollection = (ChartCollection) getChartCollection();
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
if (vanChart == null) {
return;
}
TopDefinitionProvider filterDefinition = vanChart.getFilterDefinition();
if (filterDefinition == null) {
return;
}
TwoTuple<String, String[]> tableNameAndDataFields = filterDefinition.getTableNameAndDataFields();
if (tableNameAndDataFields == null) {
return;
}
String tableName = tableNameAndDataFields.getFirst();
String[] dataFields = tableNameAndDataFields.getSecond();
autoChartTypePane.populate(tableName, dataFields);
}
}

104
designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java

@ -0,0 +1,104 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.script.Calculator;
import javax.swing.Icon;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartIcon implements Icon {
private static final int WIDTH = 500;
private static final int HEIGHT = 281;
private ChartCollection chartCollection;
private CallbackEvent callbackEvent;
private String chartName;
public AutoChartIcon(ChartCollection chartCollection) {
this.chartCollection = chartCollection;
initChartName();
}
public ChartCollection getChartCollection() {
return chartCollection;
}
public String getChartName() {
return chartName;
}
private void initChartName() {
Chart chart = chartCollection.getSelectedChart(Chart.class);
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID());
chartName = subName[0];
}
public void registerCallBackEvent(CallbackEvent callbackEvent) {
this.callbackEvent = callbackEvent;
}
/**
* 画出缩略图Icon
*
* @param g 图形的上下文
* @param c 所在的Component
* @param x 缩略图的起始坐标x
* @param y 缩略图的起始坐标y
*/
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createAutoTypeInfo(), getIconWidth(), getIconHeight());
int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
g.translate(x, y);
g2d.setPaint(Color.white);
g2d.fillRect(0, 0, getIconWidth(), getIconHeight());
painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent);
g.translate(-x, -y);
g2d.setPaint(oldPaint);
}
/**
* 返回缩略图的宽度
*
* @return int 缩略图宽度
*/
@Override
public int getIconWidth() {
return WIDTH;
}
/**
* 返回缩略图的高度
*
* @return int 缩略图高度
*/
@Override
public int getIconHeight() {
return HEIGHT;
}
}

291
designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java

@ -0,0 +1,291 @@
package com.fr.design.chart;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.chart.auto.AutoTypeCalculate;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionListener;
import javax.swing.plaf.SplitPaneUI;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.awt.Color;
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;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent {
private JList chartViewList;
private DefaultListModel chartResultModel;
private UIButton refreshButton;
private TableDataComboBox tableNameComboBox;
private UIComboCheckBox dataFieldBox;
private AutoProgressBar connectionBar;
private SwingWorker worker;
public AutoChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initButtonGroup();
initRefreshLabel();
initDataFiledBox();
JPanel contentPane = createContentPane();
chartViewList = new JList();
chartResultModel = new DefaultListModel();
chartViewList.setModel(chartResultModel);
chartViewList.setVisibleRowCount(0);
chartViewList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
chartViewList.setCellRenderer(iconCellRenderer);
JScrollPane subListPane = new JScrollPane(chartViewList);
subListPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Recommended_Chart")));
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, contentPane, subListPane);
SplitPaneUI ui = splitPane.getUI();
if (ui instanceof BasicSplitPaneUI) {
((BasicSplitPaneUI) ui).getDivider().setBorder(null);
}
splitPane.setDividerLocation(60);
this.add(splitPane);
}
ListCellRenderer iconCellRenderer = new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.setText("");
AutoChartIcon chartIcon = (AutoChartIcon) value;
this.setIcon(chartIcon);
setHorizontalAlignment(UILabel.CENTER);
if (isSelected) {
// 深蓝色.
this.setBackground(new Color(57, 107, 181));
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName(), Color.WHITE));
} else {
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName()));
}
return this;
}
};
private JPanel createContentPane() {
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(tableDataPane);
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":"));
tableNameComboBox.setPreferredSize(new Dimension(126, 20));
tableDataPane.add(tableNameComboBox);
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(areaNamePane);
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":"));
areaNamePane.add(dataFieldBox);
panel.add(refreshButton);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
return panel;
}
private void initButtonGroup() {
dataFieldBox = new UIComboCheckBox(new Object[0]);
dataFieldBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkButtonState();
}
});
}
private void initDataFiledBox() {
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
refreshBox();
checkButtonState();
}
}
});
}
private void checkButtonState() {
if (tableNameComboBox.getSelectedItem() != null && dataFieldBox.getSelectedValues().length > 0) {
refreshButton.setEnabled(true);
} else {
refreshButton.setEnabled(false);
}
}
public void registsListAction(ListSelectionListener listSelectionListener) {
chartViewList.addListSelectionListener(listSelectionListener);
}
private void refreshBox() {
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem();
if (dataWrap == null) {
return;
}
dataFieldBox.clearText();
List<String> columnNameList = dataWrap.calculateColumnNameList();
dataFieldBox.refreshCombo(columnNameList.toArray());
}
private void initRefreshLabel() {
refreshButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Recommend"));
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshButton.setEnabled(false);
calculateAutoChart();
}
});
refreshButton.setEnabled(false);
}
private void calculateAutoChart() {
connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Chart_Generate_Recommended_Chart"), "", 0, 100) {
public void doMonitorCanceled() {
refreshButton.setEnabled(true);
worker.cancel(true);
}
};
setWorker();
worker.execute();
}
private void setWorker() {
worker = new SwingWorker<List<VanChart>, Void>() {
protected List<VanChart> doInBackground() {
connectionBar.start();
chartResultModel.clear();
List<String> columnList = new ArrayList<>();
Object[] selectedValues = dataFieldBox.getSelectedValues();
for (Object value : selectedValues) {
columnList.add(GeneralUtils.objectToString(value));
}
List<VanChart> vanChartList = AutoTypeCalculate.calculateType(tableNameComboBox.getSelectedItem().getTableDataName(), columnList);
connectionBar.close();
return vanChartList;
}
public void done() {
try {
List<VanChart> vanChartList = get();
if (vanChartList != null && !vanChartList.isEmpty()) {
for (VanChart vanChart : vanChartList) {
ChartCollection chartCollection = new ChartCollection(vanChart);
AutoChartIcon autoChartIcon = new AutoChartIcon(chartCollection);
autoChartIcon.registerCallBackEvent(AutoChartTypePane.this);
chartResultModel.addElement(autoChartIcon);
}
chartViewList.setSelectedIndex(0);
}
} catch (Exception e) {
if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(AutoChartTypePane.this, e.getMessage(),
Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
} finally {
connectionBar.close();
refreshButton.setEnabled(true);
}
}
};
}
@Override
public void populate(ChartCollection cc) {
}
@Override
public void update(ChartCollection cc) {
update(cc, null);
}
public void populate(String tableName, String[] dataFields) {
tableNameComboBox.setSelectedTableDataByName(tableName);
Map<Object, Boolean> map = new HashMap();
for (String dataField : dataFields) {
map.put(dataField, true);
}
dataFieldBox.setSelectedValues(map);
if (refreshButton.isEnabled()) {
refreshButton.setEnabled(false);
calculateAutoChart();
}
}
public void update(ChartCollection cc, String createTime) {
if (chartViewList.getSelectedIndex() < 0) {
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
VanChart vanChart = chartIcon.getChartCollection().getSelectedChartProvider(VanChart.class);
if (cc.getChartCount() > 0) {
VanChart selectedChartProvider = cc.getSelectedChartProvider(VanChart.class);
if (selectedChartProvider.getChartUuid() != null) {
vanChart.setUuid(selectedChartProvider.getChartUuid());
}
cc.setSelectChart(vanChart);
ChartInfoCollector.getInstance().updateChartTypeTime(vanChart, null, true);
} else {
cc.addChart(vanChart);
//记录埋点
ChartInfoCollector.getInstance().collection(vanChart, createTime, false, true);
}
}
@Override
public void callback() {
this.repaint();
}
}

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

@ -39,6 +39,7 @@ public class ChartDesignerActivator extends Activator implements Prepare {
DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class);
DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class);
DesignModuleFactory.registerAutoChartDialogClass(AutoChartDialog.class);
DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);

50
designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java

@ -5,11 +5,13 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
@ -18,6 +20,7 @@ import java.awt.event.ActionListener;
/** /**
* 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框. * 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框.
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-1-7 下午07:29:15 * @version 创建时间2013-1-7 下午07:29:15
*/ */
@ -27,6 +30,7 @@ public class ChartDialog extends MiddleChartDialog {
private UIButton ok; private UIButton ok;
private UIButton cancel; private UIButton cancel;
private ChartTypePane chartTypePane;
public ChartDialog(Frame owner) { public ChartDialog(Frame owner) {
super(owner); super(owner);
@ -39,43 +43,57 @@ public class ChartDialog extends MiddleChartDialog {
} }
private void initComponent() { private void initComponent() {
final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
this.setModal(true); this.setModal(true);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
final ChartTypePane chartTypePane = new ChartTypePane(); setTitle(getDialogTitle());
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type"));
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
this.applyClosingAction(); this.applyClosingAction();
this.applyEscapeAction(); this.applyEscapeAction();
this.setBasicDialogSize(BasicDialog.DEFAULT); this.setBasicDialogSize(BasicDialog.DEFAULT);
this.add(chartTypePane, BorderLayout.CENTER); this.add(initCenterPane(), BorderLayout.CENTER);
JPanel buttonPane = new JPanel(); JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH); this.add(buttonPane, BorderLayout.SOUTH);
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); ok.addActionListener(getActionListener(createTime));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
}
});
buttonPane.add(ok); buttonPane.add(ok);
buttonPane.add(cancel); buttonPane.add(cancel);
ok.addActionListener(new ActionListener() { GUICoreUtils.setWindowCenter(getOwner(), this);
}
protected String getDialogTitle() {
return Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type");
}
protected Component initCenterPane() {
chartTypePane = new ChartTypePane();
return chartTypePane;
}
protected ActionListener getActionListener(final String createTime) {
return new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
chartTypePane.update((ChartCollection) cc, createTime); chartTypePane.update((ChartCollection) cc, createTime);
doOK(); doOK();
} }
}); };
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
} }
});
GUICoreUtils.setWindowCenter(getOwner(), this);
public UIButton getOk() {
return ok;
} }
/** /**

143
designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java

@ -0,0 +1,143 @@
package com.fr.design.chart.auto;
import com.fr.chart.auto.ColumnInfo;
import com.fr.chart.auto.strategy.AutoTypeStrategy;
import com.fr.chart.auto.strategy.imp.AvaStrategy;
import com.fr.chart.auto.strategy.imp.BubbleChartStrategy;
import com.fr.chart.auto.strategy.imp.SingleDimensionStrategy;
import com.fr.chart.auto.strategy.imp.SingleTargetStrategy;
import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.NameTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.data.DataModel;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-08
*/
public class AutoTypeCalculate {
public static List<VanChart> calculateType(String tableName, List<String> columns) {
List<ColumnInfo> columnValue = calculateField(tableName, columns);
if (columnValue.isEmpty()) {
return new ArrayList<>();
}
List<ColumnInfo> dimensions = new ArrayList<>();
List<ColumnInfo> targets = new ArrayList<>();
for (ColumnInfo field : columnValue) {
if (isTarget(field.getValues())) {
targets.add(field);
} else {
dimensions.add(field);
}
}
AutoTypeStrategy autoTypeStrategy = chooseStrategy(dimensions.size(), targets.size());
return autoTypeStrategy.rankChart(tableName, dimensions, targets);
}
private static AutoTypeStrategy chooseStrategy(int dimensionSize, int targetSize) {
if (dimensionSize == 0) {
//没有维度,并且只有一个指标,使用单指标匹配逻辑,大于1个指标,使用气泡图(散点图)匹配逻辑
if (targetSize == 1) {
return new SingleTargetStrategy();
} else {
return new BubbleChartStrategy();
}
} else if (dimensionSize == 1) {
//1个维度,并且没有指标,使用单维度匹配,2~3个指标,使用气泡图(散点图)匹配逻辑,其余使用ava匹配
if (targetSize == 0) {
return new SingleDimensionStrategy();
} else if (targetSize == 2 || targetSize == 3) {
return new BubbleChartStrategy();
} else {
return new AvaStrategy();
}
} else {
//大与1个维度,并且没有指标,使用单维度匹配(循环),否则使用ava匹配
if (targetSize == 0) {
return new SingleDimensionStrategy();
} else {
return new AvaStrategy();
}
}
}
private static boolean isTarget(List<String> values) {
for (String value : values) {
if (StringUtils.isEmpty(value)) {
continue;
}
Number number = GeneralUtils.string2Number(value);
if (number == null) {
return false;
}
}
return true;
}
private static List<ColumnInfo> calculateField(String tableName, List<String> columns) {
NameTableData nameTableData = new NameTableData(tableName);
TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
Calculator calculator = Calculator.createCalculator();
calculator.setAttribute(TableDataSource.KEY, dataSource);
nameTableData.createTableData(calculator);
EmbeddedTableData tableData;
try {
tableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, nameTableData, Integer.MAX_VALUE, false);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new ArrayList<>();
}
List<ColumnInfo> originalData = new ArrayList<>();
for (String column : columns) {
List<String> columnData = getColumnData(tableData, column);
if (columnData != null && !columnData.isEmpty()) {
originalData.add(new ColumnInfo(column, columnData));
}
}
return originalData;
}
private static List<String> getColumnData(EmbeddedTableData tableData, String columnName) {
List<String> columnData = new ArrayList<>();
int colIndex = getColIndex(tableData, columnName);
if (colIndex == DataModel.COLUMN_NAME_NOT_FOUND) {
return columnData;
}
int size = tableData.getRowCount();
for (int i = 0; i < size; i++) {
Object valueAt = tableData.getValueAt(i, colIndex);
columnData.add(GeneralUtils.objectToString(valueAt));
}
return columnData;
}
private static int getColIndex(EmbeddedTableData tableData, String columnName) {
int colIndex = 0;
for (int count = tableData.getColumnCount(); colIndex < count; ++colIndex) {
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(colIndex), columnName)) {
return colIndex;
}
}
return DataModel.COLUMN_NAME_NOT_FOUND;
}
}

3
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -140,6 +140,9 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public void paintComponent(Graphics g) { // public void paintComponent(Graphics g) { //
super.paintComponent(g); super.paintComponent(g);
if(chartCollection4Design.getChartCount() == 0) {
return;
}
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;

9
designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java

@ -2,6 +2,8 @@ package com.fr.design.chartx.component.combobox;
import com.fr.base.ChartColorMatching; import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.cert.token.lang.Collections;
import com.fr.chart.base.ChartConstants;
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;
@ -60,6 +62,7 @@ public class ColorSchemeComboBox extends UIComboBox {
//添加默认的方案和第一个方案 //添加默认的方案和第一个方案
String defaultName = config.getCurrentStyle(); String defaultName = config.getCurrentStyle();
ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName); ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName);
if (names.hasNext()) {
Object firstName = names.next(); Object firstName = names.next();
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName); ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName);
if (defaultStyle == null) { if (defaultStyle == null) {
@ -67,6 +70,12 @@ public class ColorSchemeComboBox extends UIComboBox {
} }
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle)); colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle));
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle)); colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle));
} else {
ColorInfo colorInfo = new ColorInfo();
colorInfo.setGradient(false);
colorInfo.setColors(Collections.arrayToList(ChartConstants.CHART_COLOR_ARRAY));
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorInfo);
}
//添加其他的配色方案 //添加其他的配色方案
while (names.hasNext()) { while (names.hasNext()) {

69
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -6,31 +6,38 @@ import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicScrollPane; import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox; import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox;
import com.fr.design.mainframe.chart.gui.item.ItemEventType; import com.fr.design.mainframe.chart.gui.item.ItemEventType;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* 图表 属性表, 类型选择 界面. * 图表 属性表, 类型选择 界面.
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-26 上午10:56:51 * @version 创建时间2012-12-26 上午10:56:51
*/ */
@ -39,9 +46,11 @@ public class ChartTypePane extends AbstractChartAttrPane{
private ChartTypeButtonPane buttonPane; private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane; private ChartEditPane editPane;
private ChartCollection editingCollection; private ChartCollection editingCollection;
private ActionListener autoButtonListener;
@Override @Override
protected JPanel createContentPane() { protected JPanel createContentPane() {
initButtonListener();
JPanel content = new JPanel(new BorderLayout()); JPanel content = new JPanel(new BorderLayout());
buttonPane = new ChartTypeButtonPane(this); buttonPane = new ChartTypeButtonPane(this);
@ -91,12 +100,44 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 界面标题 * 界面标题
*
* @return 界面标题 * @return 界面标题
*/ */
public String title4PopupWindow() { public String title4PopupWindow() {
return PaneTitleConstants.CHART_TYPE_TITLE; return PaneTitleConstants.CHART_TYPE_TITLE;
} }
public void initButtonListener() {
autoButtonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String lastId = editingCollection.getSelectedChartProvider(ChartProvider.class).getID();
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(editingCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
populate(editingCollection);
ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class);
reLayoutEditPane(chart, lastId);
}
});
autoChartDialog.setVisible(true);
}
};
}
private void reLayoutEditPane(ChartProvider chart, String lastChartId) {
String chartId = chart.getID();
//chartID改变的话图表类型就算改变了
if (StringUtils.isNotEmpty(chartId)) {
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartId);
if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastChartId, chartId))) {
editPane.reLayout(chart);
}
}
}
class ComboBoxPane extends UIComboBoxPane<ChartProvider> { class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane; private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;
@ -104,7 +145,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
protected List<FurtherBasicBeanPane<? extends ChartProvider>> initPaneList() { protected List<FurtherBasicBeanPane<? extends ChartProvider>> initPaneList() {
List<FurtherBasicBeanPane<? extends ChartProvider>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartProvider>>(); List<FurtherBasicBeanPane<? extends ChartProvider>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartProvider>>();
allChartTypePane = new LinkedHashMap<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>>(); allChartTypePane = new LinkedHashMap<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>>();
ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane); ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener);
return paneList; return paneList;
} }
@ -117,6 +158,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
* 不同图表切换分同一个selected的不同图表切换和不同selected的不同图表切换 * 不同图表切换分同一个selected的不同图表切换和不同selected的不同图表切换
* 如果是切换图表的某个图表发生变化则collection的选择下标不会变 * 如果是切换图表的某个图表发生变化则collection的选择下标不会变
* 如果是切换图表的不同图表之间切换则collection的选择下标会改变 * 如果是切换图表的不同图表之间切换则collection的选择下标会改变
*
* @param chart * @param chart
*/ */
public void updateBean(ChartProvider chart) { public void updateBean(ChartProvider chart) {
@ -139,17 +181,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
//这一步会替换plot //这一步会替换plot
((AbstractChartTypePane) getSelectedPane()).updateBean(chart); ((AbstractChartTypePane) getSelectedPane()).updateBean(chart);
String chartID = chart.getID(); reLayoutEditPane(chart,lastPlotID);
//chartID改变的话图表类型就算改变了
if (StringUtils.isNotEmpty(chartID)) {
boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID);
if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, chartID))) {
editPane.reLayout(chart);
}
}
} }
protected UIComboBox createComboBox() { protected UIComboBox createComboBox() {
@ -290,6 +322,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 面板重构 * 面板重构
*
* @param lastPlotID * @param lastPlotID
* @param collection * @param collection
*/ */
@ -340,6 +373,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 所有图表的类型界面 * 所有图表的类型界面
*
* @return 类型界面 * @return 类型界面
*/ */
public FurtherBasicBeanPane[] getPaneList() { public FurtherBasicBeanPane[] getPaneList() {
@ -348,6 +382,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 当前选中的图表的index * 当前选中的图表的index
*
* @return 当前选中的图表的index * @return 当前选中的图表的index
*/ */
public int getSelectedIndex() { public int getSelectedIndex() {
@ -356,6 +391,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 返回选中的图表的index * 返回选中的图表的index
*
* @return 选中的图标的序号 * @return 选中的图标的序号
*/ */
public int getSelectedChartIndex() { public int getSelectedChartIndex() {
@ -364,6 +400,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
/** /**
* 设置下编辑的面板 * 设置下编辑的面板
*
* @param currentEditPane 设置下编辑的面板 * @param currentEditPane 设置下编辑的面板
*/ */
public void registerChartEditPane(ChartEditPane currentEditPane) { public void registerChartEditPane(ChartEditPane currentEditPane) {

49
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java

@ -6,11 +6,11 @@ import com.fr.chart.chartattr.MeterPlot;
import com.fr.chart.chartdata.MeterReportDefinition; import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane; import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -20,16 +20,19 @@ import java.awt.Component;
/** /**
* 仪表盘 属性表 单元格数据界面 * 仪表盘 属性表 单元格数据界面
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午02:47:57 * @version 创建时间2012-12-21 下午02:47:57
*/ */
public class MeterPlotReportDataContentPane extends AbstractReportDataContentPane { public class MeterPlotReportDataContentPane extends AbstractReportDataContentPane {
private static final String CATENAME = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Name"); private static final String CATENAME = Toolkit.i18nText("Fine-Design_Chart_Category_Name");
private static final String NVALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Value"); private static final String NVALUE = Toolkit.i18nText("Fine-Design_Chart_Value_Pointer");
private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value");
private TinyFormulaPane singCatePane; private TinyFormulaPane singCatePane;
private TinyFormulaPane singValuePane; public TinyFormulaPane singValuePane;
private TinyFormulaPane customPane;
private ChartDataFilterPane filterPane; private ChartDataFilterPane filterPane;
public MeterPlotReportDataContentPane(ChartDataPane parent) { public MeterPlotReportDataContentPane(ChartDataPane parent) {
@ -45,16 +48,12 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {p, f}; double[] columnSize = {p, f};
double[] rowSize = { p, p, p}; double[] rowSize = getRowSize();
Component[][] components = new Component[][]{ Component[][] components = getShowComponents();
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
new Component[]{null, null}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 24, 6); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 24, 6);
panel.setBorder(BorderFactory.createEmptyBorder(0,24,0,15)); panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 5, 8));
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(panel, BorderLayout.NORTH); this.add(panel, BorderLayout.NORTH);
@ -66,6 +65,19 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
this.add(pane, BorderLayout.CENTER); this.add(pane, BorderLayout.CENTER);
} }
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p, p};
}
protected Component[][] getShowComponents() {
return new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
new Component[]{new UILabel(TARGET_VALUE), customPane = new TinyFormulaPane()}
};
}
protected String getCateNameString() { protected String getCateNameString() {
return CATENAME; return CATENAME;
} }
@ -85,11 +97,18 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
if (meterDefinition.getValue() != null) { if (meterDefinition.getValue() != null) {
singValuePane.getUITextField().setText(meterDefinition.getValue().toString()); singValuePane.getUITextField().setText(meterDefinition.getValue().toString());
} }
if (meterDefinition.getTarget() != null) {
populateCustomPane(meterDefinition.getTarget().toString());
}
} }
filterPane.populateBean(collection); filterPane.populateBean(collection);
} }
protected void populateCustomPane(String target) {
customPane.getUITextField().setText(target);
}
protected void populateSingCatePane(String name) { protected void populateSingCatePane(String name) {
singCatePane.getUITextField().setText(name); singCatePane.getUITextField().setText(name);
} }
@ -103,12 +122,20 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
meterDefinition.setValue(canBeFormula(singValuePane.getUITextField().getText())); meterDefinition.setValue(canBeFormula(singValuePane.getUITextField().getText()));
updateCustomPane(meterDefinition);
collection.getSelectedChart().setFilterDefinition(meterDefinition); collection.getSelectedChart().setFilterDefinition(meterDefinition);
filterPane.updateBean(collection); filterPane.updateBean(collection);
} }
} }
protected void updateCustomPane(MeterReportDefinition meterDefinition) {
meterDefinition.setTarget(canBeFormula(customPane.getUITextField().getText()));
}
protected void updateSingCatePane(MeterReportDefinition meterDefinition) { protected void updateSingCatePane(MeterReportDefinition meterDefinition) {
meterDefinition.setName(canBeFormula(singCatePane.getUITextField().getText())); meterDefinition.setName(canBeFormula(singCatePane.getUITextField().getText()));

106
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java

@ -4,73 +4,121 @@ import com.fr.base.Utils;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.MeterPlot; import com.fr.chart.chartattr.MeterPlot;
import com.fr.chart.chartdata.MeterTableDefinition; import com.fr.chart.chartdata.MeterTableDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.layout.TableLayout; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane; import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.extended.chart.StringFormula;
import com.fr.extended.chart.UIComboBoxWithNone;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.util.List; import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* 仪表盘, 属性表, 数据集数据界面. * 仪表盘, 属性表, 数据集数据界面.
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午04:51:50 * @version 创建时间2012-12-21 下午04:51:50
*/ */
public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane { public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane {
private static final String METER_NAME = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"); private static final String METER_NAME = Toolkit.i18nText("Fine-Design_Chart_Category_Name");
private static final String METER_VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Value"); private static final String METER_VALUE = Toolkit.i18nText("Fine-Design_Chart_Value_Pointer");
private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value");
private static final int COMBOBOX_WIDTH = 115;
private static final int COMBOBOX_HEIGHT = 20;
private static final int LABEL_WIDTH = 85;
private UIComboBox nameBox; private UIComboBox nameBox;
private UIComboBox valueBox; private UIComboBox valueBox;
private UIComboBox targetBox;
private TinyFormulaPane custom;
private ChartDataFilterPane filterPane; private ChartDataFilterPane filterPane;
private JPanel boxPane;
public MeterPlotTableDataContentPane(ChartDataPane parent) { public MeterPlotTableDataContentPane(ChartDataPane parent) {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
nameBox = new UIComboBox(); nameBox = new UIComboBoxWithNone();
valueBox = new UIComboBox(); valueBox = new UIComboBox();
targetBox = new UIComboBox();
custom = new TinyFormulaPane();
filterPane = new ChartDataFilterPane(new MeterPlot(), parent); filterPane = new ChartDataFilterPane(new MeterPlot(), parent);
double p = TableLayout.PREFERRED; boxPane = new JPanel();
double f = TableLayout.FILL; boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS));
double[] columnSize = {f, COMPONENT_WIDTH};
double[] rowSize = {p, p}; JPanel namePane = createPaneWithLabel(Toolkit.i18nText(METER_NAME), getNameComponent());
boxPane.add(namePane);
JPanel valuePane = createPaneWithLabel(Toolkit.i18nText(METER_VALUE), valueBox);
boxPane.add(valuePane);
JPanel targetPane = createPaneWithLabel(Toolkit.i18nText(TARGET_VALUE), targetBox);
boxPane.add(targetPane);
Component[][] components = createComponents(); final JPanel customPane = createPaneWithLabel(StringUtils.EMPTY, custom);
boxPane.add(customPane);
customPane.setVisible(false);
initTargetBoxValue();
targetBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (targetBox.getSelectedIndex() == targetBox.getItemCount() - 1) {
customPane.setVisible(true);
} else {
customPane.setVisible(false);
}
}
});
JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), filterPane); JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), filterPane);
JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
filterPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); filterPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15));
panel.setBorder(BorderFactory.createEmptyBorder(10,24,10,15)); boxPane.setBorder(BorderFactory.createEmptyBorder(7, 24, 7, 15));
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 5)); jPanel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 5));
this.add(getJSeparator(), BorderLayout.NORTH); this.add(getJSeparator(), BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER); this.add(boxPane, BorderLayout.CENTER);
this.add(jPanel, BorderLayout.SOUTH); this.add(jPanel, BorderLayout.SOUTH);
nameBox.addItemListener(tooltipListener); nameBox.addItemListener(tooltipListener);
valueBox.addItemListener(tooltipListener); valueBox.addItemListener(tooltipListener);
targetBox.addItemListener(tooltipListener);
} }
private Component[][] createComponents() { private JPanel createPaneWithLabel(String labelName, Component component) {
return new Component[][]{ component.setPreferredSize(new Dimension(COMBOBOX_WIDTH, COMBOBOX_HEIGHT));
new Component[]{new BoldFontTextLabel(METER_NAME), getNameComponent()}, UILabel label = new BoldFontTextLabel(labelName);
new Component[]{new BoldFontTextLabel(METER_VALUE), valueBox}, label.setPreferredSize(new Dimension(LABEL_WIDTH, COMBOBOX_HEIGHT));
}; JPanel paneWithLabel = GUICoreUtils.createBorderLayoutPane(new Component[]{component, null, null, label, null});
paneWithLabel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
return paneWithLabel;
} }
protected void refreshBoxListWithSelectTableData(List list) { protected void refreshBoxListWithSelectTableData(List list) {
refreshBoxItems(nameBox, list); refreshBoxItems(nameBox, list);
refreshBoxItems(valueBox, list); refreshBoxItems(valueBox, list);
refreshBoxItems(targetBox, list);
initTargetBoxValue();
} }
/** /**
@ -81,6 +129,11 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
clearBoxItems(valueBox); clearBoxItems(valueBox);
} }
private void initTargetBoxValue() {
targetBox.addItem(Toolkit.i18nText("Fine-Design_Chart_Custom"));
targetBox.setSelectedItem(null);
}
/** /**
* 更新仪表盘数据界面 * 更新仪表盘数据界面
*/ */
@ -91,6 +144,12 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
populateNameComponent(meter); populateNameComponent(meter);
valueBox.setSelectedItem(meter.getValue()); valueBox.setSelectedItem(meter.getValue());
custom.getUITextField().setText(meter.getCustomTarget().getContent());
if (meter.isCustom()) {
targetBox.setSelectedIndex(targetBox.getItemCount() - 1);
} else {
targetBox.setSelectedItem(meter.getTargetValue());
}
filterPane.populateBean(ob); filterPane.populateBean(ob);
} }
} }
@ -110,6 +169,13 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
updateNameComponent(meter); updateNameComponent(meter);
meter.setValue(Utils.objectToString(valueBox.getSelectedItem())); meter.setValue(Utils.objectToString(valueBox.getSelectedItem()));
if (targetBox.getSelectedIndex() == targetBox.getItemCount() - 1) {
meter.setCustom(true);
meter.setCustomTarget(new StringFormula(custom.getUITextField().getText()));
} else {
meter.setCustom(false);
meter.setTargetValue(GeneralUtils.objectToString(targetBox.getSelectedItem()));
}
filterPane.updateBean(ob); filterPane.updateBean(ob);
} }
} }

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java

@ -22,6 +22,7 @@ import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionListener;
public abstract class AbstractChartTypePane<T extends ChartProvider> extends FurtherBasicBeanPane<T> { public abstract class AbstractChartTypePane<T extends ChartProvider> extends FurtherBasicBeanPane<T> {
@ -240,4 +241,8 @@ public abstract class AbstractChartTypePane<T extends ChartProvider> extends Fur
public ChartProvider getDefaultChart() { public ChartProvider getDefaultChart() {
return BarIndependentChart.barChartTypes[0]; return BarIndependentChart.barChartTypes[0];
} }
public void registerButtonListener(ActionListener autoButtonListener) {
}
} }

92
designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java

@ -2,11 +2,13 @@ package com.fr.design.module;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ChartEmptyDataStyleConf; import com.fr.base.ChartEmptyDataStyleConf;
import com.fr.base.Style;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane; import com.fr.design.style.background.image.ImagePreviewPane;
@ -14,7 +16,7 @@ import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper; import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -24,6 +26,7 @@ import javax.swing.JFileChooser;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.io.File;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@ -32,7 +35,6 @@ import java.awt.GridLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
/** /**
* Created by mengao on 2017/11/23. * Created by mengao on 2017/11/23.
@ -47,8 +49,10 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private UIButtonGroup emptyData; private UIButtonGroup emptyData;
private UILabel imageContent;
private UIButtonGroup imageData;
private UIRadioButton defaultRadioButton; private UIRadioButton defaultRadioButton;
private UIRadioButton customRadioButton; private UIRadioButton adjustRadioButton;
private UIButton selectPictureButton; private UIButton selectPictureButton;
private ImagePreviewPane previewPane; private ImagePreviewPane previewPane;
@ -72,7 +76,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
} }
private JPanel creatNorthPane() { private JPanel creatNorthPane() {
emptyData = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); emptyData = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")});
emptyData.setSelectedIndex(0); emptyData.setSelectedIndex(0);
emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT)); emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
emptyData.addActionListener(new ActionListener() { emptyData.addActionListener(new ActionListener() {
@ -83,8 +87,24 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
} }
}); });
UILabel promptContent = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Tip_Content")); imageData = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")});
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0); imageData.setSelectedIndex(0);
imageData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
imageData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
emptyDataImage = null;
checkIsCustom();
repaintPreviewPane();
}
});
UILabel promptContent = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Tip_Content"));
imageContent = new UILabel(Toolkit.i18nText("Fine-Design_Report_Image"));
JPanel emptyPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0);
JPanel imagePane = GUICoreUtils.createFlowPane(new Component[]{imageContent, imageData}, FlowLayout.LEFT, TEN, 0);
imagePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{emptyPane, imagePane}, FlowLayout.LEFT, 0, 0);
northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0)); northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0));
return northPane; return northPane;
} }
@ -96,7 +116,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPane.add(previewContainerPane, BorderLayout.CENTER); centerPane.add(previewContainerPane, BorderLayout.CENTER);
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Preview"));
previewOwnerPane.setLayout(new BorderLayout()); previewOwnerPane.setLayout(new BorderLayout());
previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER);
previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST); previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST);
@ -116,25 +136,27 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY)); selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY));
defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); defaultRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Default"));
customRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Custom")); adjustRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Image_Adjust"));
ButtonGroup buttonGroup = new ButtonGroup(); ButtonGroup buttonGroup = new ButtonGroup();
defaultRadioButton.setSelected(true); defaultRadioButton.setSelected(true);
buttonGroup.add(defaultRadioButton); buttonGroup.add(defaultRadioButton);
buttonGroup.add(customRadioButton); buttonGroup.add(adjustRadioButton);
defaultRadioButton.setEnabled(false);
adjustRadioButton.setEnabled(false);
defaultRadioButton.addActionListener(getLayoutActionListener()); defaultRadioButton.addActionListener(getLayoutActionListener());
customRadioButton.addActionListener(getLayoutActionListener()); adjustRadioButton.addActionListener(getLayoutActionListener());
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(defaultRadioButton);
jp.add(customRadioButton);
selectPictureButton = new UIButton( selectPictureButton = new UIButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select")); Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select"));
selectPictureButton.setEnabled(false);
selectPictureButton.addActionListener(getSelectPictureActionListener()); selectPictureButton.addActionListener(getSelectPictureActionListener());
jp.add(selectPictureButton);
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(selectPictureButton);
jp.add(defaultRadioButton);
jp.add(adjustRadioButton);
selectFilePane.add(jp, BorderLayout.NORTH); selectFilePane.add(jp, BorderLayout.NORTH);
return selectFilePane; return selectFilePane;
@ -142,10 +164,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private ActionListener getLayoutActionListener() { private ActionListener getLayoutActionListener() {
return new ActionListener() { return new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
emptyDataImage = null; setImageStyle();
checkCustomImage();
repaintPreviewPane(); repaintPreviewPane();
} }
}; };
@ -188,17 +208,30 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private void checkEmptyDataStyle() { private void checkEmptyDataStyle() {
boolean b = emptyData.getSelectedIndex() == 0; boolean b = emptyData.getSelectedIndex() == 0;
defaultRadioButton.setVisible(b);
adjustRadioButton.setVisible(b);
selectPictureButton.setVisible(b);
imageContent.setVisible(b);
imageData.setVisible(b);
}
private void checkIsCustom() {
boolean b = imageData.getSelectedIndex() == 1;
defaultRadioButton.setEnabled(b); defaultRadioButton.setEnabled(b);
customRadioButton.setEnabled(b); adjustRadioButton.setEnabled(b);
selectPictureButton.setEnabled(b); selectPictureButton.setEnabled(b);
} }
private void checkCustomImage() { private void setImageStyle() {
selectPictureButton.setVisible(customRadioButton.isSelected()); if (adjustRadioButton.isSelected()) {
previewPane.setImageStyle(Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST));
} else {
previewPane.setImageStyle(Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER));
}
} }
private void repaintPreviewPane() { private void repaintPreviewPane() {
emptyDataImage = customRadioButton.isSelected() ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE; emptyDataImage = imageData.getSelectedIndex() == 1 ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE;
previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null); previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null);
previewPane.repaint(); previewPane.repaint();
} }
@ -215,12 +248,14 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
public void populateBean() { public void populateBean() {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance(); ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() == true ? 0 : 1); emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() ? 0 : 1);
customRadioButton.setSelected(manager.isCustomEmptyDataStyle()); imageData.setSelectedIndex(manager.isCustomEmptyDataStyle() ? 1 : 0);
adjustRadioButton.setSelected(manager.isAdjust());
emptyDataImage = manager.getEmptyDataImage(); emptyDataImage = manager.getEmptyDataImage();
checkEmptyDataStyle(); checkEmptyDataStyle();
checkCustomImage(); checkIsCustom();
setImageStyle();
repaintPreviewPane(); repaintPreviewPane();
} }
@ -228,7 +263,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance(); ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0); manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0);
manager.setCustomEmptyDataStyle(customRadioButton.isSelected()); manager.setCustomEmptyDataStyle(imageData.getSelectedIndex() == 1);
manager.setAdjust(adjustRadioButton.isSelected());
manager.setEmptyDataImage(emptyDataImage); manager.setEmptyDataImage(emptyDataImage);
} }
} }

7
designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java

@ -2,6 +2,7 @@ package com.fr.van.chart.bubble;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.i18n.Toolkit;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -53,7 +54,7 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane {
//设置色彩面板内容 //设置色彩面板内容
@Override @Override
protected void setColorPaneContent(JPanel panel) { protected void setColorPaneContent(JPanel panel) {
panel.add(createAlphaPane(), BorderLayout.CENTER); panel.add(createAlphaPane(), BorderLayout.SOUTH);
} }
@Override @Override
@ -67,7 +68,7 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane {
@Override @Override
public String getPaneTitle() { public String getPaneTitle() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); return Toolkit.i18nText("Fine-Design_Chart_Custom_Axis");
} }
}; };
stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane);
@ -76,7 +77,7 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane {
private JPanel createBubblePane() { private JPanel createBubblePane() {
bubblePane = new VanChartBubblePane(); bubblePane = new VanChartBubblePane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Bubble"), bubblePane); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Bubble"), bubblePane);
} }
protected void populateCondition(ConditionAttr defaultAttr) { protected void populateCondition(ConditionAttr defaultAttr) {

4
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnConditionPane.java

@ -17,11 +17,11 @@ import com.fr.plugin.chart.base.AttrTooltip;
import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.plugin.chart.base.VanChartAttrTrendLine;
import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.type.ConditionKeyType; import com.fr.plugin.chart.type.ConditionKeyType;
import com.fr.van.chart.designer.other.condition.item.VanChartColumnSeriesColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartDataSheetContentPane; import com.fr.van.chart.designer.other.condition.item.VanChartDataSheetContentPane;
import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartSeriesImageBackgroundConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesImageBackgroundConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartTrendLineConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTrendLineConditionPane;
@ -46,7 +46,7 @@ public class VanChartColumnConditionPane extends DataSeriesConditionPane{
@Override @Override
protected void addBasicAction() { protected void addBasicAction() {
classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(AttrBackground.class, new VanChartColumnSeriesColorConditionPane(this));
classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this));
classPaneMap.put(AttrBorder.class, new VanChartColumnLabelBorderPane(this)); classPaneMap.put(AttrBorder.class, new VanChartColumnLabelBorderPane(this));
classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot)); classPaneMap.put(AttrLabel.class, new VanChartLabelConditionPane(this, plot));

21
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java

@ -3,6 +3,7 @@ package com.fr.van.chart.column;
import com.fr.base.background.ImageBackground; import com.fr.base.background.ImageBackground;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.i18n.Toolkit;
import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -17,6 +18,8 @@ import com.fr.plugin.chart.base.AttrSeriesImageBackground;
import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartBeautyPaneWithGradientBar;
import com.fr.van.chart.designer.component.border.VanChartBorderPane; import com.fr.van.chart.designer.component.border.VanChartBorderPane;
import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -70,28 +73,28 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
private JPanel createSeriesStylePane(double[] row, double[] col) { private JPanel createSeriesStylePane(double[] row, double[] col) {
isFixedWidth = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_YES"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NO")}); isFixedWidth = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")});
columnWidth = new UISpinner(0,1000,1,0); columnWidth = new UISpinner(0,1000,1,0);
columnWidth.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); columnWidth.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0));
seriesGap = new UINumberDragPane(-100, 100); seriesGap = new UINumberDragPane(-100, 100);
categoryGap = new UINumberDragPane(0, 100); categoryGap = new UINumberDragPane(0, 100);
isFillWithImage = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_YES"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NO")}); isFillWithImage = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Fine-Design_Chart_YES"), Toolkit.i18nText("Fine-Design_Chart_NO")});
imagePane = new ImageBackgroundQuickPane(false); imagePane = new ImageBackgroundQuickPane(false);
imagePane.setBorder(BorderFactory.createEmptyBorder(0,(int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); imagePane.setBorder(BorderFactory.createEmptyBorder(0,(int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0));
JPanel panel1 = new JPanel(new BorderLayout()); JPanel panel1 = new JPanel(new BorderLayout());
JPanel isFixedWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed_Column_Width"),isFixedWidth); JPanel isFixedWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Fixed_Column_Width"),isFixedWidth);
isFixedWidthPane.setBorder(BorderFactory.createEmptyBorder(0,0,6,0)); isFixedWidthPane.setBorder(BorderFactory.createEmptyBorder(0,0,6,0));
panel1.add(isFixedWidthPane, BorderLayout.NORTH); panel1.add(isFixedWidthPane, BorderLayout.NORTH);
panel1.add(columnWidth, BorderLayout.CENTER); panel1.add(columnWidth, BorderLayout.CENTER);
Component[][] components2 = new Component[][]{ Component[][] components2 = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gap_Series")),seriesGap}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Series")),seriesGap},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gap_Category")),categoryGap}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gap_Category")),categoryGap},
}; };
JPanel panel2 = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, row, col); JPanel panel2 = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, row, col);
UILabel fillImageLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image")); UILabel fillImageLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image"));
Component[][] components3 = new Component[][]{ Component[][] components3 = new Component[][]{
new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)}, new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)},
}; };
@ -117,7 +120,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
checkImagePane(); checkImagePane();
} }
}); });
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), borderPane); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), borderPane);
} }
private void checkAll() { private void checkAll() {
@ -131,6 +134,10 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane {
seriesGap.setEnabled(!b); seriesGap.setEnabled(!b);
} }
protected VanChartBeautyPane createStylePane() {
return new VanChartBeautyPaneWithGradientBar();
}
private void checkImagePane() { private void checkImagePane() {
imagePane.setVisible(isFillWithImage.getSelectedIndex() == 0); imagePane.setVisible(isFillWithImage.getSelectedIndex() == 0);
} }

1
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java

@ -27,6 +27,7 @@ public class VanChartCustomDataPane extends ChartDataPane {
} }
contentsTabPane = new VanChartCustomPlotDataContentsTabPane((VanChartCustomPlot)chart.getPlot(), VanChartCustomDataPane.this, listener); contentsTabPane = new VanChartCustomPlotDataContentsTabPane((VanChartCustomPlot)chart.getPlot(), VanChartCustomDataPane.this, listener);
contentsTabPane.setSupportCellData(isSupportCellData());
content.add(contentsTabPane, BorderLayout.CENTER); content.add(contentsTabPane, BorderLayout.CENTER);
return content; return content;

19
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java

@ -22,10 +22,21 @@ import java.util.Map;
* Created by Fangjie on 2016/4/29. * Created by Fangjie on 2016/4/29.
*/ */
public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTabPane<VanChartCustomPlot, ChartCollection> { public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTabPane<VanChartCustomPlot, ChartCollection> {
private boolean supportCellData;
public VanChartCustomPlotDataContentsTabPane(VanChartCustomPlot plot, VanChartCustomDataPane parent, AttributeChangeListener listener) { public VanChartCustomPlotDataContentsTabPane(VanChartCustomPlot plot, VanChartCustomDataPane parent, AttributeChangeListener listener) {
super(plot, parent, listener); super(plot, parent, listener);
} }
public boolean isSupportCellData() {
return supportCellData;
}
public void setSupportCellData(boolean supportCellData) {
this.supportCellData = supportCellData;
}
@Override @Override
protected void initTabTitle() { protected void initTabTitle() {
@ -60,6 +71,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
for (int i = 0; i < customPlotList.size(); i++) { for (int i = 0; i < customPlotList.size(); i++) {
//根据不同的plot创建不同的数据配置界面 //根据不同的plot创建不同的数据配置界面
ChartDataPane contentPane = new VanChartDataPane(listener); ChartDataPane contentPane = new VanChartDataPane(listener);
contentPane.setSupportCellData(supportCellData);
paneList.add(contentPane); paneList.add(contentPane);
} }
@ -71,12 +83,9 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
plot = (VanChartCustomPlot) chartCollection.getSelectedChart().getPlot(); plot = (VanChartCustomPlot) chartCollection.getSelectedChart().getPlot();
if (paneList == null){
paneList = initPaneList(); paneList = initPaneList();
}
if (paneList != null){
relayoutWhenListChange();
try { try {
List<VanChartPlot> customPlotList = plot.getCustomPlotList(); List<VanChartPlot> customPlotList = plot.getCustomPlotList();
@ -104,7 +113,6 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
return; return;
} }
} }
}
@Override @Override
public ChartCollection updateBean() { public ChartCollection updateBean() {
@ -168,6 +176,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
/** /**
* 返回绑定的属性事件. * 返回绑定的属性事件.
*
* @param listener 增加监听 * @param listener 增加监听
*/ */
public void addAttributeChangeListener(AttributeChangeListener listener) { public void addAttributeChangeListener(AttributeChangeListener listener) {

3
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

@ -61,7 +61,8 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
return new Component[][]{ return new Component[][]{
new Component[]{typePane}, new Component[]{typePane},
new Component[]{stylePane}, new Component[]{stylePane},
new Component[]{contentPane} new Component[]{contentPane},
new Component[]{buttonPane},
}; };
} }

27
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java

@ -7,9 +7,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartFillStylePane; import com.fr.van.chart.designer.component.VanChartFillStylePane;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -26,9 +24,6 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
private JPanel seriesPane; private JPanel seriesPane;
protected VanChartCustomPlotSeriesTabPane plotSeriesPane; protected VanChartCustomPlotSeriesTabPane plotSeriesPane;
private VanChartFillStylePane fillStylePane;//配色 private VanChartFillStylePane fillStylePane;//配色
private VanChartBeautyPane stylePane;//风格
public VanChartCustomSeriesPane(ChartStylePane parent) { public VanChartCustomSeriesPane(ChartStylePane parent) {
super(parent); super(parent);
@ -69,16 +64,13 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] row = {p,p}; double[] row = {p};
double[] col = {f}; double[] col = {f};
fillStylePane = new VanChartFillStylePane(); fillStylePane = new VanChartFillStylePane();
stylePane = new VanChartBeautyPane();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{fillStylePane}, //配色 new Component[]{fillStylePane} //配色
new Component[]{stylePane},//风格
}; };
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col);
@ -101,16 +93,6 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if (fillStylePane != null){ if (fillStylePane != null){
plot.setPlotFillStyle(fillStylePane.updateBean()); plot.setPlotFillStyle(fillStylePane.updateBean());
} }
if(stylePane != null) {
plot.setPlotStyle(stylePane.updateBean());
//风格属性传递
for (int i = 0; i < plot.getCustomPlotList().size(); i++){
VanChartPlot vanChartPlot = plot.getCustomPlotList().get(i);
vanChartPlot.setPlotStyle(plot.getPlotStyle());
}
}
if (seriesPane != null){ if (seriesPane != null){
plotSeriesPane.updateBean(plot); plotSeriesPane.updateBean(plot);
} }
@ -135,14 +117,9 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if(plot == null) { if(plot == null) {
return; return;
} }
if(fillStylePane != null) {//配色 if(fillStylePane != null) {//配色
fillStylePane.populateBean(plot.getPlotFillStyle()); fillStylePane.populateBean(plot.getPlotFillStyle());
} }
if(stylePane != null){//风格
stylePane.populateBean(plot.getPlotStyle());
}
//更新不同点的系列界面 //更新不同点的系列界面
plotSeriesPane.populateBean(plot); plotSeriesPane.populateBean(plot);

71
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java

@ -1,12 +1,13 @@
package com.fr.van.chart.designer.component; package com.fr.van.chart.designer.component;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.GradientStyle;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.plugin.chart.type.GradientType;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -17,56 +18,68 @@ import java.awt.Component;
* Created by Mitisky on 15/9/8. * Created by Mitisky on 15/9/8.
*/ */
//系列-风格 //系列-风格
public class VanChartBeautyPane extends BasicBeanPane<Integer> { public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
private UIButtonGroup styleBox;
private UIButtonGroup gradientTypeBox;
public UIButtonGroup getGradientTypeBox() {
return gradientTypeBox;
}
public VanChartBeautyPane() { public VanChartBeautyPane() {
styleBox = new UIButtonGroup(getNameArray()); this.setLayout(new BorderLayout());
this.add(initGradientTypePane(), BorderLayout.CENTER);
}
private JPanel initGradientTypePane() {
String[] names = getNameArray();
gradientTypeBox = new UIButtonGroup(names);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] rowSize = {p}; double[] rowSize = {p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), styleBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), gradientTypeBox},
}; };
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.add(panel,BorderLayout.CENTER);
} }
protected String[] getNameArray() { protected String[] getNameArray() {
return new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), return new String[]{
Toolkit.i18nText("Fine-Design_Chart_On"),
Toolkit.i18nText("Fine-Design_Chart_Off") Toolkit.i18nText("Fine-Design_Chart_Off")
}; };
} }
@Override
public void populateBean(Integer ob) { public void populateBean(GradientStyle gradientStyle) {
int finalIndex; gradientTypeBox.setSelectedIndex(this.convertGradientTypeToIndex(gradientStyle.getGradientType()));
switch (ob){
case ChartConstants.STYLE_NONE: finalIndex = 1; break;
case ChartConstants.STYLE_SHADE: finalIndex = 0; break;
default: finalIndex = 1;
}
styleBox.setSelectedIndex(finalIndex);
} }
@Override @Override
public Integer updateBean() { public GradientStyle updateBean() {
int index = styleBox.getSelectedIndex(); GradientStyle gradientStyle = new GradientStyle();
int style;
switch (index){ gradientStyle.setGradientType(this.convertIndexToGradientType(this.gradientTypeBox.getSelectedIndex()));
case 0: style = ChartConstants.STYLE_SHADE; break;
case 1: style = ChartConstants.STYLE_NONE; break; return gradientStyle;
default: style = ChartConstants.STYLE_NONE;
} }
return style;
protected int convertGradientTypeToIndex(GradientType gradientType) {
return gradientType == GradientType.NONE ? 1 : 0;
}
protected GradientType convertIndexToGradientType(int index) {
return index == 1 ? GradientType.NONE : GradientType.AUTO;
} }
@Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return ""; return StringUtils.EMPTY;
} }
} }

113
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPaneWithGradientBar.java

@ -0,0 +1,113 @@
package com.fr.van.chart.designer.component;
import com.fr.chart.base.GradientStyle;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.plugin.chart.type.GradientType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class VanChartBeautyPaneWithGradientBar extends VanChartBeautyPane {
private FixedGradientBar colorGradient;
private JPanel gradientBarPane;
public VanChartBeautyPaneWithGradientBar() {
super();
this.add(initGradientBarPane(), BorderLayout.SOUTH);
initListener();
}
private JPanel initGradientBarPane() {
colorGradient = new FixedGradientBar(4, 140);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{null, colorGradient},
};
gradientBarPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
return gradientBarPane;
}
private void initListener() {
getGradientTypeBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkGradientBarVisible();
}
});
}
private void checkGradientBarVisible() {
if (colorGradient != null && gradientBarPane != null) {
gradientBarPane.setVisible(getGradientTypeBox().getSelectedIndex() == 1);
}
}
protected String[] getNameArray() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Auto"),
Toolkit.i18nText("Fine-Design_Chart_Custom"),
Toolkit.i18nText("Fine-Design_Chart_Off")
};
}
public void populateBean(GradientStyle gradientStyle) {
super.populateBean(gradientStyle);
if (colorGradient != null) {
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor());
}
checkGradientBarVisible();
}
@Override
public GradientStyle updateBean() {
GradientStyle gradientStyle = super.updateBean();
if (this.colorGradient != null && this.gradientBarPane != null) {
gradientStyle.setStartColor(colorGradient.getSelectColorPointBtnP1().getColorInner());
gradientStyle.setEndColor(colorGradient.getSelectColorPointBtnP2().getColorInner());
}
return gradientStyle;
}
protected int convertGradientTypeToIndex(GradientType gradientType) {
switch (gradientType) {
case CUSTOM:
return 1;
case NONE:
return 2;
default:
return 0;
}
}
protected GradientType convertIndexToGradientType(int index) {
switch (index) {
case 1:
return GradientType.CUSTOM;
case 2:
return GradientType.NONE;
default:
return GradientType.AUTO;
}
}
}

3
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java

@ -144,8 +144,9 @@ public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> implemen
double f = TableLayout.FILL; double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] rowSize = {p, p}; double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox},
new Component[]{null, customPane}, new Component[]{null, customPane},

25
designer-chart/src/main/java/com/fr/van/chart/designer/data/OneDimensionalPlotReportDataContentPane.java

@ -1,8 +1,13 @@
package com.fr.van.chart.designer.data; package com.fr.van.chart.designer.data;
import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.MeterPlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.report.MeterPlotReportDataContentPane;
import java.awt.Component;
/** /**
@ -23,4 +28,24 @@ public class OneDimensionalPlotReportDataContentPane extends MeterPlotReportData
protected String getNValueString() { protected String getNValueString() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value");
} }
@Override
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p, p};
}
@Override
protected Component[][] getShowComponents() {
return new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
};
}
protected void populateCustomPane(String target) {
}
protected void updateCustomPane(MeterReportDefinition meterDefinition) {
}
} }

9
designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartAreaFillColorConditionPane.java

@ -1,11 +1,11 @@
package com.fr.van.chart.designer.other.condition.item; package com.fr.van.chart.designer.other.condition.item;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.base.DataSeriesCondition;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.AttrAreaSeriesFillColorBackground; import com.fr.plugin.chart.base.AttrAreaSeriesFillColorBackground;
import com.fr.plugin.chart.type.GradientType;
import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane; import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -40,6 +40,7 @@ public class VanChartAreaFillColorConditionPane extends AbstractNormalMultiLine
/** /**
* 条件属性item的名称 * 条件属性item的名称
*
* @return item的名称 * @return item的名称
*/ */
public String nameForPopupMenuItem() { public String nameForPopupMenuItem() {
@ -54,13 +55,13 @@ public class VanChartAreaFillColorConditionPane extends AbstractNormalMultiLine
public void setDefault() { public void setDefault() {
//下面这句话是给各组件一个默认值 //下面这句话是给各组件一个默认值
fillColorBackground.populate(new AttrAreaSeriesFillColorBackground()); fillColorBackground.populate(new AttrAreaSeriesFillColorBackground());
fillColorBackground.checkoutAlpha(!(plot != null && plot.getPlotStyle() == ChartConstants.STYLE_SHADE)); fillColorBackground.checkoutAlpha(plot != null && ((VanChartPlot) plot).getGradientStyle().getGradientType() == GradientType.NONE);
} }
public void populate(DataSeriesCondition condition) { public void populate(DataSeriesCondition condition) {
if (condition instanceof AttrAreaSeriesFillColorBackground) { if (condition instanceof AttrAreaSeriesFillColorBackground) {
fillColorBackground.populate((AttrAreaSeriesFillColorBackground) condition); fillColorBackground.populate((AttrAreaSeriesFillColorBackground) condition);
fillColorBackground.checkoutAlpha(!(plot != null && plot.getPlotStyle() == ChartConstants.STYLE_SHADE)); fillColorBackground.checkoutAlpha(plot != null && ((VanChartPlot) plot).getGradientStyle().getGradientType() == GradientType.NONE);
} }
} }

153
designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartColumnSeriesColorConditionPane.java

@ -0,0 +1,153 @@
package com.fr.van.chart.designer.other.condition.item;
import com.fr.base.background.ColorBackground;
import com.fr.chart.base.AttrBackground;
import com.fr.chart.base.DataSeriesCondition;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.plugin.chart.type.GradientType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class VanChartColumnSeriesColorConditionPane extends AbstractNormalMultiLineConditionPane {
private UIButtonGroup matchColorTypeBox;
private ColorSelectBox colorSelectionBox;
private FixedGradientBar colorGradient;
private JPanel colorSelectPane;
private JPanel colorGradientPane;
public VanChartColumnSeriesColorConditionPane(ConditionAttributesPane conditionAttributesPane) {
super(conditionAttributesPane, null);
}
protected String getItemLabelString() {
return nameForPopupMenuItem();
}
protected JPanel initContentPane() {
colorSelectionBox = new ColorSelectBox(80);
colorGradient = new FixedGradientBar(4, 150);
colorSelectPane = createJPanelWithComponent(colorSelectionBox);
colorGradientPane = createJPanelWithComponent(colorGradient);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(initColorButtonPane(), BorderLayout.NORTH);
panel.add(colorSelectPane, BorderLayout.CENTER);
panel.add(colorGradientPane, BorderLayout.SOUTH);
initListener();
return panel;
}
private JPanel initColorButtonPane() {
String[] names = new String[]{
Toolkit.i18nText("Fine-Design_Chart_Solid_Color"),
Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade")
};
matchColorTypeBox = new UIButtonGroup(names);
double p = TableLayout.PREFERRED;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
Component[][] components = new Component[][]{new Component[]{matchColorTypeBox}};
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, new double[]{e});
}
private void initListener() {
matchColorTypeBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkColorPaneVisible();
}
});
}
private void checkColorPaneVisible() {
if (colorSelectPane != null) {
colorSelectPane.setVisible(matchColorTypeBox.getSelectedIndex() == 0);
}
if (colorGradientPane != null) {
colorGradientPane.setVisible(matchColorTypeBox.getSelectedIndex() == 1);
}
}
public String nameForPopupMenuItem() {
return Toolkit.i18nText("Fine-Design_Chart_Match_Color");
}
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Match_Color");
}
public void populate(DataSeriesCondition condition) {
if (condition instanceof AttrBackground) {
AttrBackground matchColor = (AttrBackground) condition;
if (matchColor.getGradient() == GradientType.NONE) {
this.matchColorTypeBox.setSelectedIndex(0);
} else {
this.matchColorTypeBox.setSelectedIndex(1);
}
ColorBackground seriesColor = (ColorBackground) matchColor.getSeriesBackground();
if (seriesColor != null) {
this.colorSelectionBox.setSelectObject(seriesColor.getColor());
}
this.colorGradient.updateColor(matchColor.getGradientStartColor(), matchColor.getGradientEndColor());
}
checkColorPaneVisible();
}
public DataSeriesCondition update() {
AttrBackground matchColor = new AttrBackground();
if (this.matchColorTypeBox.getSelectedIndex() == 0) {
matchColor.setGradient(GradientType.NONE);
} else {
matchColor.setGradient(GradientType.CUSTOM);
}
matchColor.setSeriesBackground(ColorBackground.getInstance(this.colorSelectionBox.getSelectObject()));
matchColor.setGradientStartColor(this.colorGradient.getSelectColorPointBtnP1().getColorInner());
matchColor.setGradientEndColor(this.colorGradient.getSelectColorPointBtnP2().getColorInner());
return matchColor;
}
public void setDefault() {
this.populate(new AttrBackground());
}
private JPanel createJPanelWithComponent(Component component) {
double p = TableLayout.PREFERRED;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
Component[][] components = new Component[][]{
new Component[]{null},
new Component[]{component}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{e});
}
}

16
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java

@ -254,21 +254,13 @@ public class VanChartPlotLegendPane extends BasicPane {
customFloatPositionButton.addMouseListener(new MouseAdapter() { customFloatPositionButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if(!customFloatPositionButton.isSelected()){ super.mouseReleased(e);
location.setSelectedIndex(-1);
customFloatPositionButton.setSelected(true); customFloatPositionButton.setSelected(true);
checkLayoutPaneVisible(); checkLayoutPaneVisible();
checkDisplayStrategyUse(); checkDisplayStrategyUse();
}
}
@Override
public void mousePressed(MouseEvent e) {
location.setSelectedIndex(-1);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
if(customFloatPositionPane == null) { if(customFloatPositionPane == null) {
customFloatPositionPane = new VanChartFloatPositionPane(); customFloatPositionPane = new VanChartFloatPositionPane();

17
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java

@ -214,23 +214,14 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane<VanChart> {
}); });
customFloatPositionButton.addMouseListener(new MouseAdapter() { customFloatPositionButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (!customFloatPositionButton.isSelected()) {
customFloatPositionButton.setSelected(true);
checkDisplayStrategyUse();
}
}
@Override
public void mousePressed(MouseEvent e) {
alignmentPane.setSelectedIndex(-1);
}
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
super.mouseReleased(e); super.mouseReleased(e);
alignmentPane.setSelectedIndex(-1);
customFloatPositionButton.setSelected(true);
checkDisplayStrategyUse();
if (customFloatPositionPane == null) { if (customFloatPositionPane == null) {
customFloatPositionPane = new VanChartFloatPositionPane(); customFloatPositionPane = new VanChartFloatPositionPane();
} }

10
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisScrollPaneWithTypeSelect.java

@ -1,11 +1,11 @@
package com.fr.van.chart.designer.style.axis; package com.fr.van.chart.designer.style.axis;
import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Axis;
import com.fr.design.i18n.Toolkit;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartTimeAxis; import com.fr.plugin.chart.attr.axis.VanChartTimeAxis;
import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis;
@ -57,7 +57,7 @@ public class VanChartAxisScrollPaneWithTypeSelect extends AbstractVanChartScroll
protected void initLayout() { protected void initLayout() {
this.setLayout(new BorderLayout(0,6)); this.setLayout(new BorderLayout(0,6));
JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type"),jcb); JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Type"), jcb);
northPane.setBorder(BorderFactory.createEmptyBorder(0,5,0,0)); northPane.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER); this.add(cardPane, BorderLayout.CENTER);
@ -102,21 +102,21 @@ public class VanChartAxisScrollPaneWithTypeSelect extends AbstractVanChartScroll
if(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)){ if(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)){
textAxisPane.updateBean(axis); textAxisPane.updateBean(axis);
} else { } else {
axis = new VanChartAxis(axis.getAxisName(), axis.getPosition()); axis = new VanChartAxis(axis.getAxisName(), axis.getPosition(), axis.getGridLineType(), axis.getMainGridColor());
textAxisPane.updateBean(axis); textAxisPane.updateBean(axis);
} }
} else if(ComparatorUtils.equals(index, AxisType.AXIS_TIME.ordinal())){ } else if(ComparatorUtils.equals(index, AxisType.AXIS_TIME.ordinal())){
if(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_TIME)){ if(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_TIME)){
timeAxisPane.updateBean(axis); timeAxisPane.updateBean(axis);
} else { } else {
axis = new VanChartTimeAxis(axis.getAxisName(), axis.getPosition()); axis = new VanChartTimeAxis(axis.getAxisName(), axis.getPosition(), axis.getGridLineType(), axis.getMainGridColor());
timeAxisPane.updateBean(axis); timeAxisPane.updateBean(axis);
} }
} else if(ComparatorUtils.equals(index, AxisType.AXIS_VALUE.ordinal())){ } else if(ComparatorUtils.equals(index, AxisType.AXIS_VALUE.ordinal())){
if(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_VALUE)){ if(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_VALUE)){
valueAxisPane.updateBean(axis); valueAxisPane.updateBean(axis);
} else { } else {
axis = new VanChartValueAxis(axis.getAxisName(), axis.getPosition()); axis = new VanChartValueAxis(axis.getAxisName(), axis.getPosition(), axis.getGridLineType(), axis.getMainGridColor());
valueAxisPane.updateBean(axis); valueAxisPane.updateBean(axis);
} }
} }

44
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java

@ -54,11 +54,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
private static final long serialVersionUID = -5717246802333308973L; private static final long serialVersionUID = -5717246802333308973L;
private static final double ROTATION_MAX = 90.0; private static final double ROTATION_MAX = 90.0;
protected UIButtonGroup showTitle;
protected TinyFormulaPane titleContent; protected TinyFormulaPane titleContent;
protected UIButtonGroup<Integer> titleAlignPane; protected UIButtonGroup<Integer> titleAlignPane;
protected UIToggleButton titleUseHtml; protected UIToggleButton titleUseHtml;
protected ChartTextAttrPane titleTextAttrPane; protected ChartTextAttrPane titleTextAttrPane;
protected UINumberDragPane titleTextRotation; protected UINumberDragPane titleTextRotation;
protected JPanel titlePane;
protected UIButtonGroup showLabel; protected UIButtonGroup showLabel;
protected ChartTextAttrPane labelTextAttrPane; protected ChartTextAttrPane labelTextAttrPane;
@ -108,6 +110,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
public void setParentPane(VanChartStylePane parent) { public void setParentPane(VanChartStylePane parent) {
htmlLabelPane.setParent(parent); htmlLabelPane.setParent(parent);
} }
protected void reLayoutPane(boolean isXAxis) { protected void reLayoutPane(boolean isXAxis) {
this.removeAll(); this.removeAll();
this.add(createContentPane(isXAxis), BorderLayout.CENTER); this.add(createContentPane(isXAxis), BorderLayout.CENTER);
@ -123,7 +126,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
double[] column = {f, s}; double[] column = {f, s};
double[] rowSize = {p, p, p, p, p, p, p, p}; double[] rowSize = {p, p, p, p, p, p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, columnSize, isXAxis), null}, new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, column, isXAxis), null},
new Component[]{createLabelPane(new double[]{p, p}, column), null}, new Component[]{createLabelPane(new double[]{p, p}, column), null},
new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null},
new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null},
@ -135,12 +138,13 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
protected JPanel createTitlePane(double[] row, double[] col, boolean isXAxis) { protected JPanel createTitlePane(double[] row, double[] col, boolean isXAxis) {
showTitle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
titleAlignPane = isXAxis ? getXAxisTitleAlignPane() : getYAxisTitleAlignPane(); titleAlignPane = isXAxis ? getXAxisTitleAlignPane() : getYAxisTitleAlignPane();
titleAlignPane.setSelectedItem(Constants.CENTER); titleAlignPane.setSelectedItem(Constants.CENTER);
titleContent = new TinyFormulaPane(); titleContent = new TinyFormulaPane();
titleUseHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html")); titleUseHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html"));
UIComponentUtils.setLineWrap(titleUseHtml); UIComponentUtils.setLineWrap(titleUseHtml);
titleTextAttrPane = new ChartTextAttrPane(); titleTextAttrPane = getChartTextAttrPane();
titleTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); titleTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
if (isXAxis) { if (isXAxis) {
titleTextRotation.populateBean(0.0); titleTextRotation.populateBean(0.0);
@ -158,9 +162,22 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
UIComponentUtils.wrapWithBorderLayoutPane(titleTextRotation) UIComponentUtils.wrapWithBorderLayoutPane(titleTextRotation)
}, },
}; };
titlePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
titlePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); JPanel showTitlePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Title"), showTitle);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_TITLE_TITLE, panel); showTitle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkTitlePane();
}
});
JPanel jPanel = new JPanel(new BorderLayout());
jPanel.add(showTitlePane, BorderLayout.NORTH);
jPanel.add(titlePane, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_TITLE_TITLE, jPanel);
} }
private UIButtonGroup<Integer> getXAxisTitleAlignPane() { private UIButtonGroup<Integer> getXAxisTitleAlignPane() {
@ -171,6 +188,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
return new UIButtonGroup<Integer>(alignmentIconArray, alignment); return new UIButtonGroup<Integer>(alignmentIconArray, alignment);
} }
private UIButtonGroup<Integer> getYAxisTitleAlignPane() { private UIButtonGroup<Integer> getYAxisTitleAlignPane() {
Icon[] alignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), Icon[] alignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"),
@ -462,6 +480,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected void checkAllUse() { protected void checkAllUse() {
checkCardPane(); checkCardPane();
checkLabelPane(); checkLabelPane();
checkTitlePane();
//区域显示策略 恢复用注释。删除下面一行。 //区域显示策略 恢复用注释。删除下面一行。
checkMaxProPortionUse(); checkMaxProPortionUse();
@ -505,6 +524,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
} }
} }
protected void checkTitlePane() {
if (showTitle != null && titlePane != null) {
titlePane.setVisible(showTitle.getSelectedIndex() == 0);
}
}
private void checkLabelGapAndStylePane() { private void checkLabelGapAndStylePane() {
if (overlapHandleTypeGroup != null && labelGapStylePane != null) { if (overlapHandleTypeGroup != null && labelGapStylePane != null) {
boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL; boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
@ -528,6 +553,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
/** /**
* 是否是指定类型 * 是否是指定类型
*
* @param ob 对象 * @param ob 对象
* @return 是否是指定类型 * @return 是否是指定类型
*/ */
@ -537,6 +563,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
/** /**
* title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到 * title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到
*
* @return 绥化狂标题 * @return 绥化狂标题
*/ */
@Override @Override
@ -550,6 +577,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
public void reset() { public void reset() {
} }
@Override @Override
public void populateBean(VanChartAxis axis) { public void populateBean(VanChartAxis axis) {
populateTitle(axis); populateTitle(axis);
@ -569,6 +597,9 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
//标题 //标题
private void populateTitle(VanChartAxis axis) { private void populateTitle(VanChartAxis axis) {
if (showTitle != null) {
showTitle.setSelectedIndex(axis.isShowAxisTitle() ? 0 : 1);
}
Title axisTitle = axis.getTitle(); Title axisTitle = axis.getTitle();
if (axisTitle != null) { if (axisTitle != null) {
if (axisTitle.getTextObject() instanceof BaseFormula && titleContent != null) { if (axisTitle.getTextObject() instanceof BaseFormula && titleContent != null) {
@ -690,8 +721,12 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
updateFormat(axis); updateFormat(axis);
} }
//标题 //标题
private void updateTitle(VanChartAxis axis) { private void updateTitle(VanChartAxis axis) {
if (showTitle != null) {
axis.setShowAxisTitle(showTitle.getSelectedIndex() == 0);
}
Title axisTitle = axis.getTitle(); Title axisTitle = axis.getTitle();
if (axisTitle == null) { if (axisTitle == null) {
axisTitle = new Title(); axisTitle = new Title();
@ -810,6 +845,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
/** /**
* X坐标轴不同类型切换,new一个新的 * X坐标轴不同类型切换,new一个新的
*
* @param axisName 坐标轴名称 * @param axisName 坐标轴名称
* @return 新的axis * @return 新的axis
*/ */

8
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java

@ -27,15 +27,15 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.Pattern;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.Pattern;
/** /**
* 时间坐标轴 * 时间坐标轴
@ -68,7 +68,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
double[] column = {f, s}; double[] column = {f, s};
double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitlePane(new double[]{p, p, p, p, p,p}, columnSize, isXAxis),null}, new Component[]{createTitlePane(new double[]{p, p, p, p, p,p}, column, isXAxis),null},
new Component[]{createLabelPane(new double[]{p, p}, column),null}, new Component[]{createLabelPane(new double[]{p, p}, column),null},
new Component[]{createValueDefinition(),null}, new Component[]{createValueDefinition(),null},
new Component[]{createLineStylePane(new double[]{p, p,p,p,p}, columnSize),null}, new Component[]{createLineStylePane(new double[]{p, p,p,p,p}, columnSize),null},

2
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java

@ -49,7 +49,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane {
double[] column = {f, s}; double[] column = {f, s};
double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p,p,p,p,p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, columnSize, isXAxis), null}, new Component[]{createTitlePane(new double[]{p, p, p, p, p, p}, column, isXAxis), null},
new Component[]{createLabelPane(new double[]{p, p}, column), null}, new Component[]{createLabelPane(new double[]{p, p}, column), null},
new Component[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null}, new Component[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null},
new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null},

33
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java

@ -9,7 +9,6 @@ import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis; import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis;
import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.gauge.VanChartGaugePlot;
@ -18,7 +17,6 @@ import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.VanChartValueAxisPane; import com.fr.van.chart.designer.style.axis.VanChartValueAxisPane;
import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick;
import com.fr.van.chart.designer.style.axis.component.VanChartMinMaxValuePane; import com.fr.van.chart.designer.style.axis.component.VanChartMinMaxValuePane;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -112,7 +110,36 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
switch (gaugeStyle) { switch (gaugeStyle) {
case RING: case RING:
case SLOT: case SLOT:
minMaxValuePane = new MinMaxValuePaneWithOutTick(); minMaxValuePane = new VanChartMinMaxValuePane() {
@Override
protected double[] getRowSize(double p) {
return new double[]{p};
}
@Override
protected Component[][] getShowComponents(JPanel minPaneWithCheckBox, JPanel maxPaneWithCheckBox, JPanel mainPaneWithCheckBox, JPanel secPaneWithCheckBox) {
return new Component[][]{
{minPaneWithCheckBox},
};
}
};
break;
case THERMOMETER:
minMaxValuePane = new VanChartMinMaxValuePane() {
@Override
protected double[] getRowSize(double p) {
return new double[]{p, p, p};
}
@Override
protected Component[][] getShowComponents(JPanel minPaneWithCheckBox, JPanel maxPaneWithCheckBox, JPanel mainPaneWithCheckBox, JPanel secPaneWithCheckBox) {
return new Component[][]{
{minPaneWithCheckBox},
{mainPaneWithCheckBox},
{secPaneWithCheckBox},
};
}
};
break; break;
default: default:
minMaxValuePane = new VanChartMinMaxValuePane(); minMaxValuePane = new VanChartMinMaxValuePane();

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

Loading…
Cancel
Save