Browse Source

Pull request #2: Final/10.0

Merge in ~NEIL/design from final/10.0 to feature/10.0

* commit 'c4d9d5213862f1acef4b738380025af8d42cc81c': (375 commits)
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  合代码冲突
  REPORT-32162 替换 ui 的时候,需要在事件分发线程中
  CHART-14022 所有可以设置通用格式的面板排布都不对
  CHART-13962 为趋势线条件属性设置默认值
  删除多余代码
  REPORT-32043 10.0冒烟:设计器启动经常白屏,卡住
  MOBILE-27000 移动端控件图标支持自定义颜色
  REPORT-32105 表单关闭后 JForm对象未释放 导致设计器最终发生oom
  REPORT-32073 fix 换个好名字
  REPORT-32073【冒烟测试】模板web属性-工具栏编辑之后,点确定,弹窗无法缩回
  REPORT-32088【组件加密】@harrison集群安装出现初始化失败 插件接口的位置有点问题, 不能放到 form 下, 要放到 design 下
  ...
research/11.0
neil 5 years ago
parent
commit
3c949f68a2
  1. 59
      designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java
  2. 21
      designer-base/src/main/java/com/fr/common/report/ReportState.java
  3. 99
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 11
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  5. 6
      designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java
  6. 14
      designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java
  7. 37
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  8. 10
      designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java
  9. 16
      designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java
  10. 50
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java
  11. 68
      designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java
  12. 2
      designer-base/src/main/java/com/fr/design/constants/UIConstants.java
  13. 2
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  14. 36
      designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java
  15. 10
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  16. 34
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  17. 4
      designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java
  18. 3
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java
  19. 15
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java
  20. 46
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  21. 11
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java
  22. 5
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  23. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java
  24. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java
  25. 20
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java
  26. 9
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java
  27. 13
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java
  28. 10
      designer-base/src/main/java/com/fr/design/dialog/TipDialog.java
  29. 5
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  30. 6
      designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java
  31. 70
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java
  32. 3
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java
  33. 5
      designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java
  34. 13
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  35. 17
      designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java
  36. 11
      designer-base/src/main/java/com/fr/design/event/RemoveListener.java
  37. 16
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  38. 40
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  39. 4
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  40. 3
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java
  41. 4
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java
  42. 10
      designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java
  43. 38
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  44. 34
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  45. 6
      designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java
  46. 28
      designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java
  47. 21
      designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java
  48. 45
      designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java
  49. 57
      designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java
  50. 23
      designer-base/src/main/java/com/fr/design/fun/DesignerStartClassProcessor.java
  51. 43
      designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java
  52. 25
      designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java
  53. 39
      designer-base/src/main/java/com/fr/design/fun/ReportLengthUNITProvider.java
  54. 39
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java
  55. 17
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java
  56. 23
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerStartClassProcessorProcessor.java
  57. 23
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormAdaptiveConfigUIProcessor.java
  58. 25
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java
  59. 42
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportLengthUNITProvider.java
  60. 10
      designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java
  61. 12
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  62. 13
      designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java
  63. 24
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java
  64. 38
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java
  65. 16
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java
  66. 121
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButtonUI.java
  67. 16
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  68. 61
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  69. 8
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  70. 10
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java
  71. 2
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java
  72. 10
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  73. 112
      designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java
  74. 6
      designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java
  75. 3
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java
  76. 25
      designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java
  77. 62
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  78. 16
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  79. 33
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  80. 17
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java
  81. 9
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java
  82. 88
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  83. 108
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  84. 7
      designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java
  85. 14
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  86. 3
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java
  87. 107
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java
  88. 9
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java
  89. 5
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  90. 3
      designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java
  91. 0
      designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java
  92. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java
  93. 16
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java
  94. 50
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java
  95. 153
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java
  96. 5
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java
  97. 108
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  98. 123
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java
  99. 38
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java
  100. 396
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java
  101. Some files were not shown because too many files have changed in this diff Show More

59
designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java

@ -0,0 +1,59 @@
package com.fr.common.detect;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.web.WebSocketConfig;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/10
*/
public class CommonPortDetector {
private static final CommonPortDetector INSTANCE = new CommonPortDetector();
private ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(new NamedThreadFactory("CommonPortDetector"));
public static CommonPortDetector getInstance() {
return INSTANCE;
}
public void execute() {
service.submit(new Runnable() {
@Override
public void run() {
detectTomcatPort();
detectWebSocketPort();
}
});
}
private void detectTomcatPort() {
int port = DesignerEnvManager.getEnvManager().getEmbedServerPort();
if (checkPort(port)) {
FineLoggerFactory.getLogger().error("EmbedTomcat Port: {} is not available, maybe occupied by other programs, please check it!", port);
}
}
private void detectWebSocketPort() {
Integer[] ports = WebSocketConfig.getInstance().getPort();
for (int port : ports) {
if (checkPort(port)) {
FineLoggerFactory.getLogger().error("WebSocKet Port: {} is not available, maybe occupied by other programs, please check it!", port);
}
}
}
private boolean checkPort(int port) {
try (Socket socket = new Socket("localhost", port)) {
return true;
} catch (Exception e) {
return false;
}
}
}

21
designer-base/src/main/java/com/fr/common/report/ReportState.java

@ -0,0 +1,21 @@
package com.fr.common.report;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/27
*/
public enum ReportState {
STOP("stop"), ACTIVE("active");
private String value;
ReportState(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}

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

@ -1,5 +1,6 @@
package com.fr.design; package com.fr.design;
import com.fr.common.report.ReportState;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -14,7 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.write.submit.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.GeneralContext;
@ -24,9 +25,13 @@ import com.fr.json.JSONArray;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe;
import com.fr.process.engine.core.CarryMessageEvent;
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.EnvChangedListener;
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;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
@ -43,7 +48,11 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -127,6 +136,11 @@ public class EnvChangeEntrance {
} }
} }
}); });
// REPORT-25688如果是war包部署的服务器,给与提示
if (WorkContext.getCurrent().isWarDeploy()) {
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE);
}
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
@ -213,6 +227,53 @@ public class EnvChangeEntrance {
* 对选择的环境做服务检测 * 对选择的环境做服务检测
* @param selectedEnv 选择的工作环境 * @param selectedEnv 选择的工作环境
*/ */
public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception {
//是否需要做服务校验
if(needCheckBranch(selectedEnv)) {
String localBranch;
String remoteBranch;
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
localBranch = GeneralUtils.readFullBuildNO();
try {
remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch();
} catch (WorkspaceConnectionException e) {
remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(localBranch);
}
//通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本)
if (localBranch.contains("#") && localBranch.equals(remoteBranch)) {
//说明版本一致,仅做日志记录
FineLoggerFactory.getLogger().info("Remote Designer version consistency");
} else {
localBranch = formatBranch(localBranch);
remoteBranch = formatBranch(remoteBranch);
Set<Class> noExistServiceSet = getNoExistServiceSet(connectionInfo);
StringBuilder textBuilder = new StringBuilder();
for (Class clazz : noExistServiceSet) {
WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class);
if(workspaceAPI == null){
FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz);
continue;
}
if(workspaceAPI.ignore()){
continue;
}
String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description());
textBuilder.append(descriptionOfCN).append("\n");
}
String areaText = textBuilder.toString();
if(StringUtils.isEmpty(areaText)){
return;
}
CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch);
dialog.setVisible(true);
}
}
}
/**
* 对选择的环境做服务检测
* @param selectedEnv 选择的工作环境
*/
public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception {
//是否需要做服务校验 //是否需要做服务校验
if(needCheckBranch(selectedEnv)) { if(needCheckBranch(selectedEnv)) {
@ -249,12 +310,32 @@ public class EnvChangeEntrance {
/** /**
* 判断是否需要做版本验证判断依据为 * 判断是否需要做版本验证判断依据为
* 1选择的环境为远程环境 * 1选择的环境为远程环境
* 2一个月内不弹出是否勾选这里预留还未实际增加 * 2一个月内不弹出是否勾选
* @param selectedEnv 选择的环境 * @param selectedEnv 选择的环境
* @return * @return
*/ */
private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){ private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){
return selectedEnv.getType() == DesignerWorkspaceType.Remote; if(selectedEnv.getType() == DesignerWorkspaceType.Remote){
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
if(StringUtils.isEmpty(selectedEnv.getRemindTime())){
return true;
}
//获取记录的时间
Date remindTime = format.parse(selectedEnv.getRemindTime());
calendar.setTime(remindTime);
//获取一个月后的时间
calendar.add(Calendar.MONTH,1);
//与当前时间作对比,然后判断是否提示
if(new Date().after(calendar.getTime())){
return true;
}
} catch (ParseException e) {
return true;
}
}
return false;
} }
/** /**
@ -304,7 +385,7 @@ public class EnvChangeEntrance {
return noExistServiceSet; return noExistServiceSet;
} catch (Exception e){ } catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(),e); FineLoggerFactory.getLogger().error(e.getMessage(),e);
return null; return noExistServiceSet;
} }
} }
@ -315,7 +396,7 @@ public class EnvChangeEntrance {
*/ */
private String formatBranch(String branch){ private String formatBranch(String branch){
if(branch.contains("#")){ if(branch.contains("#")){
return branch.substring(branch.lastIndexOf("#") + 1, branch.length() - 13); return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13);
} }
return branch; return branch;
} }
@ -360,6 +441,10 @@ public class EnvChangeEntrance {
* 处理异常 * 处理异常
*/ */
public void dealEvnExceptionWhenStartDesigner() { public void dealEvnExceptionWhenStartDesigner() {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe();
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(currentEnvName); envListPane.populateEnvManager(currentEnvName);
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
@ -367,6 +452,7 @@ public class EnvChangeEntrance {
@Override @Override
public void doOk() { public void doOk() {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} }
@ -374,7 +460,8 @@ public class EnvChangeEntrance {
@Override @Override
public void doCancel() { public void doCancel() {
DesignerExiter.getInstance().execute(); } DesignerExiter.getInstance().execute();
}
}); });
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }

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

@ -153,7 +153,14 @@ public class RestartHelper {
} finally { } finally {
WorkContext.getCurrent().close(); WorkContext.getCurrent().close();
frame.dispose(); frame.dispose();
try {
// 更新升级过渡用 供当前测试 后面可删除
Class.forName("com.fr.exit.DesignerExiter");
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} catch (Exception ignore) {
} finally {
System.exit(0);
}
} }
} }
@ -195,7 +202,11 @@ public class RestartHelper {
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (DesignerContext.getDesignerFrame() != null) {
DesignerContext.getDesignerFrame().exit(); DesignerContext.getDesignerFrame().exit();
} else {
DesignerExiter.getInstance().execute();
}
} }
} }
} }

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

@ -42,11 +42,15 @@ public class TableDataSourceAction extends TemplateComponentAction<JTemplate<?,
populate(tds); populate(tds);
} }
}; };
BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null); final BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null);
reportTableDataDialog.addDialogActionListener(new DialogActionAdapter() { reportTableDataDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
if (!tableDataPane.isNamePermitted()) {
reportTableDataDialog.setDoOKSucceed(false);
return;
}
DesignModelAdapter.getCurrentModelAdapter().renameTableData(tableDataPane.getDsNameChangedMap()); DesignModelAdapter.getCurrentModelAdapter().renameTableData(tableDataPane.getDsNameChangedMap());
tableDataPane.update(tds); tableDataPane.update(tds);
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());

14
designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java

@ -260,6 +260,13 @@ public class ActionFactory {
} }
} }
public static void referCellInsertActionClass(Class<?>[] cls) {
if (cls != null) {
actionClasses.clear();
Collections.addAll(actionClasses, cls);
}
}
/** /**
* 生成单元格插入相关的Action * 生成单元格插入相关的Action
* 表单中报表块编辑需要屏蔽掉"插入子报表" * 表单中报表块编辑需要屏蔽掉"插入子报表"
@ -318,6 +325,13 @@ public class ActionFactory {
} }
} }
public static void referFloatInsertActionClass(Class<?>[] cls) {
if (cls != null) {
floatActionClasses.clear();
Collections.addAll(floatActionClasses, cls);
}
}
/** /**
* 生成悬浮元素插入相关的Action * 生成悬浮元素插入相关的Action
* *

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

@ -28,6 +28,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -38,6 +39,7 @@ import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.os.OperatingSystem;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
@ -148,9 +150,6 @@ public class PreferencePane extends BasicPane {
private UIColorButton paginationLineColorTBButton; private UIColorButton paginationLineColorTBButton;
private UICheckBox supportCellEditorDefCheckBox;
private UICheckBox isDragPermitedCheckBox;
private UITextField logExportDirectoryField; private UITextField logExportDirectoryField;
private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox; private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox;
@ -198,7 +197,6 @@ public class PreferencePane extends BasicPane {
createFunctionPane(generalPane); createFunctionPane(generalPane);
createEditPane(generalPane); createEditPane(generalPane);
createGuiOfGridPane(generalPane);
createColorSettingPane(generalPane); createColorSettingPane(generalPane);
createVcsSettingPane(generalPane); createVcsSettingPane(generalPane);
@ -218,15 +216,17 @@ public class PreferencePane extends BasicPane {
oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables"));
oraclePane.add(oracleSpace); oraclePane.add(oracleSpace);
if (!OperatingSystem.isLinux()) {
JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager"));
useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager"));
upmSelectorPane.add(useOptimizedUPMCheckbox); upmSelectorPane.add(useOptimizedUPMCheckbox);
advancePane.add(upmSelectorPane); advancePane.add(upmSelectorPane);
}
JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager")); JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager"));
useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager"));
dbmSelectorPane.add(useUniverseDBMCheckbox); //dbmSelectorPane.add(useUniverseDBMCheckbox);
advancePane.add(dbmSelectorPane); //advancePane.add(dbmSelectorPane);
JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Product_Improve")); JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Product_Improve"));
joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve")); joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve"));
@ -444,18 +444,6 @@ public class PreferencePane extends BasicPane {
} }
private void createGuiOfGridPane(JPanel generalPane) {
// GridPane
JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Grid"));
generalPane.add(guiOfGridPane);
supportCellEditorDefCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Cell_Editor_Definition"));
guiOfGridPane.add(supportCellEditorDefCheckBox);
isDragPermitedCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Is_Drag_Permited"));
guiOfGridPane.add(isDragPermitedCheckBox);
}
private void createColorSettingPane(JPanel generalPane) { private void createColorSettingPane(JPanel generalPane) {
// Color Setting Pane // Color Setting Pane
JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors")); JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors"));
@ -588,7 +576,7 @@ public class PreferencePane extends BasicPane {
pageLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH")}); pageLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH")});
pageLengthComboBox.setPreferredSize(new Dimension(80, 20)); pageLengthComboBox.setPreferredSize(new Dimension(80, 20));
pageLengthComboBox.setMinimumSize(new Dimension(80, 20)); pageLengthComboBox.setMinimumSize(new Dimension(80, 20));
reportLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH"), i18nText("Fine-Design_Report_Unit_PT_Duplicate")}); reportLengthComboBox = new UIComboBox(UnitConvertUtil.getUnitItems());
reportLengthComboBox.setPreferredSize(new Dimension(80, 20)); reportLengthComboBox.setPreferredSize(new Dimension(80, 20));
reportLengthComboBox.setMinimumSize(new Dimension(80, 20)); reportLengthComboBox.setMinimumSize(new Dimension(80, 20));
UILabel pagelengthLabel = new UILabel(i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":"); UILabel pagelengthLabel = new UILabel(i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":");
@ -693,9 +681,6 @@ public class PreferencePane extends BasicPane {
useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval()); useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval());
gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable()); gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable());
gcButton.setEnabled(gcEnableCheckBox.isSelected()); gcButton.setEnabled(gcEnableCheckBox.isSelected());
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited());
gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor()); gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor());
paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor()); paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor());
@ -711,7 +696,9 @@ public class PreferencePane extends BasicPane {
this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
if (useOptimizedUPMCheckbox != null) {
useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM());
}
useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM());
@ -763,12 +750,8 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setDefaultStringToFormula(defaultStringToFormulaBox.isSelected()); designerEnvManager.setDefaultStringToFormula(defaultStringToFormulaBox.isSelected());
designerEnvManager.setSupportCellEditorDef(supportCellEditorDefCheckBox.isSelected());
designerEnvManager.setAutoCompleteShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : shortCutLabel.getText()); designerEnvManager.setAutoCompleteShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : shortCutLabel.getText());
designerEnvManager.setDragPermited(isDragPermitedCheckBox.isSelected());
designerEnvManager.setGridLineColor(gridLineColorTBButton.getColor()); designerEnvManager.setGridLineColor(gridLineColorTBButton.getColor());
designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor()); designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor());
@ -832,7 +815,9 @@ public class PreferencePane extends BasicPane {
Configurations.update(new Worker() { Configurations.update(new Worker() {
@Override @Override
public void run() { public void run() {
if (useOptimizedUPMCheckbox != null) {
ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected());
}
ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected()); ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected());
} }

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

@ -72,11 +72,11 @@ public class AboutPane extends JPanel {
addPhoneAndQQPane(contentPane); addPhoneAndQQPane(contentPane);
// 官网 // 官网
JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL)); JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireConf("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL));
// 支持邮箱 // 支持邮箱
String defaultEmail = CloudCenter.getInstance().acquireUrlByKind("support.email", ProductConstants.SUPPORT_EMAIL); String defaultEmail = CloudCenter.getInstance().acquireConf("support.email", ProductConstants.SUPPORT_EMAIL);
JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + GeneralContext.getLocale(), defaultEmail)); JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Email"), CloudCenter.getInstance().acquireConf("support.email." + GeneralContext.getLocale(), defaultEmail));
contentPane.add(urlActionPane); contentPane.add(urlActionPane);
contentPane.add(emailPane); contentPane.add(emailPane);
@ -96,7 +96,7 @@ public class AboutPane extends JPanel {
if (GeneralContext.getLocale().equals(Locale.US)) { if (GeneralContext.getLocale().equals(Locale.US)) {
return; return;
} }
boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Service_Phone") + CloudCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE)); boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Service_Phone") + CloudCenter.getInstance().acquireConf("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE));
contentPane.add(boxCenterAlignmentPane); contentPane.add(boxCenterAlignmentPane);
// 繁体版不显示QQ // 繁体版不显示QQ
if (GeneralContext.getLocale().equals(Locale.TAIWAN)) { if (GeneralContext.getLocale().equals(Locale.TAIWAN)) {
@ -176,7 +176,7 @@ public class AboutPane extends JPanel {
private String getCopyRight() { private String getCopyRight() {
return append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About_CopyRight"), COPYRIGHT_LABEL, return append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About_CopyRight"), COPYRIGHT_LABEL,
ProductConstants.HISTORY, StringUtils.BLANK, CloudCenter.getInstance().acquireUrlByKind("company.name", ProductConstants.COMPANY_NAME)); ProductConstants.HISTORY, StringUtils.BLANK, CloudCenter.getInstance().acquireConf("company.name", ProductConstants.COMPANY_NAME));
} }
private String getBuildTitle() { private String getBuildTitle() {

16
designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java

@ -27,6 +27,7 @@ import com.fr.transaction.Worker;
import com.fr.transaction.WorkerFacade; import com.fr.transaction.WorkerFacade;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -35,7 +36,8 @@ import java.util.Map;
* Global TableData. * Global TableData.
*/ */
public class GlobalTableDataAction extends UpdateAction implements ResponseDataSourceChange { public class GlobalTableDataAction extends UpdateAction implements ResponseDataSourceChange {
//private static TableDataManagerPane globalTableDataPane = new TableDataManagerPane();
private static final Dimension DEFAULT_DIMENSION = new Dimension(1000, 600);
public GlobalTableDataAction() { public GlobalTableDataAction() {
this.setMenuKeySet(SERVER_TABLEDATA); this.setMenuKeySet(SERVER_TABLEDATA);
@ -77,20 +79,10 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
} }
protected void renameConnection(final String oldName, final String newName) { protected void renameConnection(final String oldName, final String newName) {
Configurations.update(new Worker() {
@Override
public void run() {
tableDataConfig.renameTableData(oldName, newName); tableDataConfig.renameTableData(oldName, newName);
} }
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{TableDataConfig.class, ProcedureConfig.class};
}
});
}
}; };
final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null); final BasicDialog globalTableDataDialog = globalTableDataPane.showWindowWithCustomSize(designerFrame, null, DEFAULT_DIMENSION);
globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() { globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() {

50
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java

@ -0,0 +1,50 @@
package com.fr.design.base.clipboard;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.plugin.injectable.PluginModule;
import java.util.Set;
/**
* created by Harrison on 2020/05/14
**/
@SuppressWarnings({"rawtypes", "unchecked"})
public abstract class ClipboardFilter {
public static <T> T cut(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).cut(selection);
}
}
return selection;
}
public static <T> T copy(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).copy(selection);
}
}
return selection;
}
public static <T> T paste(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).paste(selection);
}
}
return selection;
}
}

68
designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java

@ -0,0 +1,68 @@
package com.fr.design.base.clipboard;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.FlavorListener;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
/**
* created by Harrison on 2020/05/11
**/
public class DesignerClipboard extends Clipboard {
private Clipboard clipboard;
public DesignerClipboard(Clipboard clipboard) {
super(clipboard.getName());
this.clipboard = clipboard;
}
@Override
public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
//处理 contents/owner
Transferable filtered = ClipboardFilter.copy(contents);
clipboard.setContents(filtered, owner);
}
@Override
public synchronized Transferable getContents(Object requestor) {
Transferable contents = clipboard.getContents(requestor);
//处理 contents
Transferable filtered = ClipboardFilter.paste(contents);
return filtered;
}
@Override
public DataFlavor[] getAvailableDataFlavors() {
return clipboard.getAvailableDataFlavors();
}
@Override
public boolean isDataFlavorAvailable(DataFlavor flavor) {
return clipboard.isDataFlavorAvailable(flavor);
}
@Override
public Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
return clipboard.getData(flavor);
}
@Override
public synchronized void addFlavorListener(FlavorListener listener) {
clipboard.addFlavorListener(listener);
}
@Override
public synchronized void removeFlavorListener(FlavorListener listener) {
clipboard.removeFlavorListener(listener);
}
@Override
public synchronized FlavorListener[] getFlavorListeners() {
return clipboard.getFlavorListeners();
}
}

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

@ -145,7 +145,6 @@ public interface UIConstants {
public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3);
public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png");
public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png");
public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png"); public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png");
@ -196,6 +195,7 @@ public interface UIConstants {
public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png");
public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png");
public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png");
public static final Icon AUTO_FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/autoForeground.png");
public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png"); public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png");
public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png"); public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png");
public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png"); public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png");

2
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -137,6 +137,8 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
nPanel.setShowText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips")); nPanel.setShowText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips"));
dg.setButtonEnabled(false); dg.setButtonEnabled(false);
} }
} else if (!BasicTableDataUtils.checkName(tempName)) {
dg.setButtonEnabled(false);
} else { } else {
nPanel.setShowText(StringUtils.BLANK); nPanel.setShowText(StringUtils.BLANK);
dg.setButtonEnabled(true); dg.setButtonEnabled(true);

36
designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java

@ -0,0 +1,36 @@
package com.fr.design.data;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/4/27
*/
public abstract class BasicTableDataUtils {
private static final int LEN = 2;
public static boolean checkName(String name) {
if (isInValidName(name)) {
FineJOptionPane.showMessageDialog(null,
Toolkit.i18nText("Fine-Design_Basic_DataSet_Rename_Warning", name),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
FineJOptionPane.WARNING_MESSAGE);
return false;
}
return true;
}
public static boolean isInValidName(String name) {
String[] values = name.split("\\.");
if (values.length == LEN) {
return (StringUtils.isNotEmpty(values[0]) && StringUtils.isNotEmpty(values[1]))
|| (StringUtils.isEmpty(values[0]) && StringUtils.isNotEmpty(values[1]));
}
return false;
}
}

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

@ -114,6 +114,7 @@ public abstract class DesignTableDataManager {
public static void closeTemplate(JTemplate<?, ?> template) { public static void closeTemplate(JTemplate<?, ?> template) {
if (template != null) { if (template != null) {
template.whenClose();
columnCache.remove(getEditingTableDataSource()); columnCache.remove(getEditingTableDataSource());
dsListenersMap.remove(template.getPath()); dsListenersMap.remove(template.getPath());
} }
@ -247,6 +248,15 @@ public abstract class DesignTableDataManager {
} }
} }
public static String[] getDsColumnNames(String dsName) {
TableDataSource dataSource = getEditingTableDataSource();
Map<String, String[]> map = columnCache.get(dataSource);
if (map == null) {
return new String[0];
}
return map.get(dsName);
}
/** /**
* august:返回当前正在编辑的具有报表数据源的模板(基本报表聚合报表) 包括 : 图表模板 * august:返回当前正在编辑的具有报表数据源的模板(基本报表聚合报表) 包括 : 图表模板
* *

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

@ -1,12 +1,10 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.TableData; 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.DialectFactory; import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -37,6 +35,7 @@ import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -61,9 +60,10 @@ import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Set;
/** /**
* @author zhou * @author zhou
@ -210,10 +210,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void initDsNameComboBox() { protected void initDsNameComboBox() {
dsNameComboBox.setRefreshingModel(true); dsNameComboBox.setRefreshingModel(true);
ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections());
List<String> dsList = new ArrayList<>();
dsList.addAll(connectionConfig.getConnections().keySet());
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList);
dsNameComboBox.setModel(dsNameComboBoxModel); dsNameComboBox.setModel(dsNameComboBoxModel);
dsNameComboBox.setRefreshingModel(false); dsNameComboBox.setRefreshingModel(false);
} }
@ -322,14 +319,31 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return null; // peter:选中了当前的零长度的节点,直接返回. return null; // peter:选中了当前的零长度的节点,直接返回.
} }
ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); ConnectionConfig connectionConfig = ConnectionConfig.getInstance();
for (Map.Entry<String, Connection> entry : connectionConfig.getConnections().entrySet()) { List<String> authConnections = getHasAuthConnections();
if (ComparatorUtils.equals(selectedDSName, entry.getKey())) { for (String name : authConnections) {
return entry.getValue(); if (ComparatorUtils.equals(selectedDSName, name)) {
return connectionConfig.getConnection(name);
} }
} }
return null; return null;
} }
private List<String> getHasAuthConnections() {
List<String> authConnections = new ArrayList<>();
Set<String> allConnections = ConnectionConfig.getInstance().getConnections().keySet();
Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections();
if (noAuthConnections == null) {
return authConnections;
}
for (String name : allConnections) {
if (!noAuthConnections.contains(name)) {
authConnections.add(name);
}
}
return authConnections;
}
/** /**
* 刷新没多大用而且要刷新也不是这儿刷新 * 刷新没多大用而且要刷新也不是这儿刷新
*/ */

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

@ -59,4 +59,8 @@ public class ReportTableDataPane extends LoadingBasicPane {
public Map<String, String> getDsNameChangedMap() { public Map<String, String> getDsNameChangedMap() {
return tdPane.getDsNameChangedMap(); return tdPane.getDsNameChangedMap();
} }
public boolean isNamePermitted() {
return tdPane.isNamePermitted();
}
} }

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

@ -35,6 +35,7 @@ public class TableDataCreatorProducer {
"ds", "ds",
"/com/fr/design/images/data/database.png", DBTableData.class, DBTableDataPane.class); "/com/fr/design/images/data/database.png", DBTableData.class, DBTableDataPane.class);
TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"),
"Class",
"/com/fr/design/images/data/source/classTableData.png", ClassTableData.class, ClassTableDataPane.class); "/com/fr/design/images/data/source/classTableData.png", ClassTableData.class, ClassTableDataPane.class);
TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"),
"Embedded", "Embedded",
@ -60,6 +61,7 @@ public class TableDataCreatorProducer {
"Proc", "Proc",
"/com/fr/design/images/data/store_procedure.png", "/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) { StoreProcedure.class, ProcedureDataPane.class) {
@Override
public boolean shouldInsertSeparator() { public boolean shouldInsertSeparator() {
return true; return true;
} }
@ -92,6 +94,7 @@ public class TableDataCreatorProducer {
}; };
TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png", TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) { StoreProcedure.class, ProcedureDataPane.class) {
@Override
public boolean shouldInsertSeparator() { public boolean shouldInsertSeparator() {
return true; return true;
} }

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

@ -5,10 +5,13 @@ import com.fr.data.impl.DBTableData;
import com.fr.design.actions.tabledata.TableDataAction; import com.fr.design.actions.tabledata.TableDataAction;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.icon.WarningIcon; import com.fr.design.icon.WarningIcon;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.Icon; import javax.swing.Icon;
@ -95,6 +98,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
* *
* @return 图片 * @return 图片
*/ */
@Override
public Icon menuIcon() { public Icon menuIcon() {
return createMenuIcon(); return createMenuIcon();
} }
@ -112,6 +116,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
* *
* @return 提示 * @return 提示
*/ */
@Override
public String createTooltip() { public String createTooltip() {
return b ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") : null; return b ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") : null;
} }
@ -166,11 +171,21 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
return false; return false;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof TableDataNameObjectCreator return obj instanceof TableDataNameObjectCreator
&& ComparatorUtils.equals(menuName, ((TableDataNameObjectCreator) obj).menuName); && ComparatorUtils.equals(menuName, ((TableDataNameObjectCreator) obj).menuName);
} }
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) {
try {
return new NameObject(helper.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@Override @Override
public int hashCode() { public int hashCode() {
return menuName == null ? 0 : menuName.hashCode(); return menuName == null ? 0 : menuName.hashCode();

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

@ -4,6 +4,7 @@ import com.fr.base.TableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.api.StoreProcedureAssist; import com.fr.data.api.StoreProcedureAssist;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
@ -14,6 +15,7 @@ import com.fr.file.ProcedureConfig;
import com.fr.file.TableDataConfig; import com.fr.file.TableDataConfig;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -47,6 +49,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName(); String tempName = getEditingName();
Object editingType = getEditingType(); Object editingType = getEditingType();
if (!BasicTableDataUtils.checkName(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
setIllegalIndex(editingIndex);
return;
}
if (StringUtils.isEmpty(tempName)) { if (StringUtils.isEmpty(tempName)) {
isNamePermitted = false; isNamePermitted = false;
nameableList.stopEditing(); nameableList.stopEditing();
@ -69,7 +79,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
} }
if (nameableList.getSelectedValue() instanceof ListModelElement) { if (nameableList.getSelectedValue() instanceof ListModelElement) {
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper;
if (!ComparatorUtils.equals(tempName, selected.getName())) { if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
rename(selected.getName(), tempName); rename(selected.getName(), tempName);
} }
@ -133,36 +143,28 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
return super.createUnrepeatedName(prefix); return super.createUnrepeatedName(prefix);
} }
String[] allDsNames = DesignTableDataManager.getAllDSNames(source); String[] allDsNames = DesignTableDataManager.getAllDSNames(source);
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = 1;
while (isDsNameRepeated(prefix + count, allDsNames)) {
count++;
}
return prefix + count;
}
private boolean isDsNameRepeated(String name, String[] allDsNames) {
DefaultListModel model = this.getModel(); DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()]; Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) { for (int i = 0; i < model.size(); i++) {
all[i] = ((ListModelElement) model.get(i)).wrapper; all[i] = ((ListModelElement) model.get(i)).wrapper;
} }
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = all.length + 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) { for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i]; Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) { if (ComparatorUtils.equals(nameable.getName(), name)) {
repeated = true; return true;
break;
}
}
for (String dsname : allDsNames) {
if (ComparatorUtils.equals(dsname, name_test)) {
repeated = true;
break;
} }
} }
return ArrayUtils.contains(allDsNames, name);
if (!repeated) {
return name_test;
}
count++;
}
} }
@Override @Override

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

@ -2,6 +2,7 @@ package com.fr.design.data.datapane;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.impl.RecursionTableData; import com.fr.data.impl.RecursionTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
@ -70,8 +71,14 @@ public class TreeTableDataComboBox extends UIComboBox {
} }
public void setSelectedTableDataByName(String name) { public void setSelectedTableDataByName(String name) {
TableDataWrapper tableDataWrappe = res_map.get(name); TableDataWrapper tableDataWrapper;
this.getModel().setSelectedItem(tableDataWrappe); if (res_map.get(name) != null) {
tableDataWrapper = res_map.get(name);
} else {
String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name);
tableDataWrapper = res_map.get(changeName);
}
this.getModel().setSelectedItem(tableDataWrapper);
} }
@Override @Override

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

@ -238,13 +238,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
isShareCheckBox.setBackground(Color.WHITE); isShareCheckBox.setBackground(Color.WHITE);
maxPanel = new MaxMemRowCountPanel(); maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null); maxPanel.setBorder(null);
JPanel wrapMaxPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
wrapMaxPanel.add(maxPanel);
wrapMaxPanel.setPreferredSize(new Dimension(250, 20));
UIToolbar editToolBar = ToolBarDef.createJToolBar(); UIToolbar editToolBar = ToolBarDef.createJToolBar();
toolBarDef.updateToolBar(editToolBar); toolBarDef.updateToolBar(editToolBar);
editToolBar.add(isShareCheckBox); editToolBar.add(isShareCheckBox);
editToolBar.add(wrapMaxPanel); editToolBar.add(maxPanel);
return editToolBar; return editToolBar;
} }

4
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java

@ -25,7 +25,7 @@ import java.util.Date;
public class EmbeddedTableDataDefinedPane extends BasicPane{ public class EmbeddedTableDataDefinedPane extends BasicPane{
private static final int MIN_CELL_WIDTH = 30;
private EmbeddedTableData tableData; private EmbeddedTableData tableData;
private JTable dataJTable; private JTable dataJTable;
private UIButton add; private UIButton add;
@ -64,7 +64,7 @@ public class EmbeddedTableDataDefinedPane extends BasicPane{
// 行号显示 // 行号显示
TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0); TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0);
tableColumn.setCellRenderer(new CellRenderer()); tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setMaxWidth(dataJTable.getColumnCount()); tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH));
// 控制按钮 // 控制按钮
add = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add")); add = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add"));

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

@ -34,6 +34,7 @@ import java.util.Date;
public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableData> { public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableData> {
private static final int MIN_CELL_WIDTH = 30;
private JTable dataJTable ; private JTable dataJTable ;
private JScrollPane scrollPane; private JScrollPane scrollPane;
private UILabel coordinatelabel; private UILabel coordinatelabel;
@ -220,7 +221,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa
// 行号显示,每次dateJTable的表结构发生变化时都要调用 // 行号显示,每次dateJTable的表结构发生变化时都要调用
TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0); TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0);
tableColumn.setCellRenderer(new CellRenderer()); tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setMaxWidth(dataJTable.getColumnCount()); tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH));
} }
private class DoubleRenderer extends DefaultTableCellRenderer { private class DoubleRenderer extends DefaultTableCellRenderer {

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

@ -4,6 +4,7 @@ import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import com.fr.base.GraphHelper;
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;
@ -15,6 +16,20 @@ import com.fr.design.gui.itoolbar.UIToolbar;
public class MaxMemRowCountPanel extends UIToolbar { public class MaxMemRowCountPanel extends UIToolbar {
private static final int ALL_IN_MEMORY = 0; private static final int ALL_IN_MEMORY = 0;
private static final int MAX_IN_MEMORY = 1; private static final int MAX_IN_MEMORY = 1;
private static final String[] CACHE_LIST = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") };
private static final int MAX_WIDTH = getMaxComBoBoxWidth() > 200 ? 350 : 250;
private static int getMaxComBoBoxWidth() {
int maxWidth = GraphHelper.getWidth(CACHE_LIST[0]);
for (int i = 1; i < CACHE_LIST.length; i++) {
int width = GraphHelper.getWidth(CACHE_LIST[i]);
if (width > maxWidth) {
maxWidth = width;
}
}
return maxWidth;
}
private UISpinner numberSpinner; private UISpinner numberSpinner;
private UIComboBox switchCache; private UIComboBox switchCache;
@ -44,7 +59,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize(); Dimension dim = super.getPreferredSize();
dim.width = 340; dim.width = MAX_WIDTH;
return dim; return dim;
}; };
@ -52,8 +67,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
this.setFloatable(false); this.setFloatable(false);
this.setRollover(true); this.setRollover(true);
this.setBackground(UIConstants.NORMAL_BACKGROUND); this.setBackground(UIConstants.NORMAL_BACKGROUND);
String[] cacheList = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") }; switchCache = new UIComboBox(CACHE_LIST);
switchCache = new UIComboBox(cacheList);
switchCache.addActionListener(switchStateL); switchCache.addActionListener(switchStateL);
numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1); numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1);
} }

9
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java

@ -33,9 +33,16 @@ public class TableDataManagerPane extends LoadingBasicPane {
); );
} }
tableDataPane = pane == null ? new TableDataPaneListPane() { tableDataPane = pane == null ? new TableDataPaneListPane() {
public void rename(String oldName, String newName) { @Override
public void rename(final String oldName, final String newName) {
super.rename(oldName, newName); super.rename(oldName, newName);
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
renameConnection(oldName, newName); renameConnection(oldName, newName);
return null;
}
}.execute();
} }
} : pane; } : pane;
container.add(tableDataPane.getPanel(), BorderLayout.CENTER); container.add(tableDataPane.getPanel(), BorderLayout.CENTER);

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

@ -50,10 +50,11 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter();
TableDataSource tds = adapter == null ? null : adapter.getBook(); TableDataSource tds = adapter == null ? null : adapter.getBook();
String[] colNames = tabledata.getColumnNames(tds); String[] colNames = tabledata.getColumnNames(tds);
String[] colNamesInCache = DesignTableDataManager.getDsColumnNames(name);
if(ArrayUtils.isNotEmpty(colNames)){ if(ArrayUtils.isNotEmpty(colNames)){
columnNameList = new ArrayList<String>(); return toColumnNameList(colNames);
columnNameList.addAll(Arrays.asList(colNames)); } else if (ArrayUtils.isNotEmpty(colNamesInCache)) {
return columnNameList; return toColumnNameList(colNamesInCache);
} }
EmbeddedTableData embeddedTableData = null; EmbeddedTableData embeddedTableData = null;
@ -69,6 +70,12 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
return columnNameList; return columnNameList;
} }
private List<String> toColumnNameList(String[] colNames) {
columnNameList = new ArrayList<>();
columnNameList.addAll(Arrays.asList(colNames));
return columnNameList;
}
/** /**
* 生成子节点 * 生成子节点
* *

10
designer-base/src/main/java/com/fr/design/dialog/TipDialog.java

@ -6,6 +6,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -39,7 +40,14 @@ public abstract class TipDialog extends JDialog implements ActionListener {
northPane.add(iconPane, BorderLayout.WEST); northPane.add(iconPane, BorderLayout.WEST);
northPane.add(tipPane, BorderLayout.CENTER); northPane.add(tipPane, BorderLayout.CENTER);
JTextArea area = new JTextArea(type); JTextPane area = new JTextPane();
UILabel typeLabel = new UILabel(type);
area.insertComponent(typeLabel);
if (StringUtils.isNotEmpty(type)) {
UILabel logoIconLabel = new UILabel();
logoIconLabel.setIcon(IOUtils.readIcon("com/fr/base/images/oem/logo.png"));
area.insertComponent(logoIconLabel);
}
area.setPreferredSize(new Dimension(400, 100)); area.setPreferredSize(new Dimension(400, 100));
area.setEnabled(true); area.setEnabled(true);
area.setEditable(false); area.setEditable(false);

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

@ -123,8 +123,11 @@ public abstract class UIDialog extends JDialog {
// transfer focus to CurrentEditor // transfer focus to CurrentEditor
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK"); inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK");
actionMap.put("dialogOK", new AbstractAction() { actionMap.put("dialogOK", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
if (!okButton.isEnabled()) {
return;
}
doOK(); doOK();
} }
}); });

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

@ -4,6 +4,7 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.js.WidgetName; import com.fr.stable.js.WidgetName;
import javax.swing.JList; import javax.swing.JList;
@ -19,6 +20,8 @@ import java.awt.Component;
* @since 2012-3-29下午6:04:37 * @since 2012-3-29下午6:04:37
*/ */
public class WidgetNameEditor extends Editor<WidgetName> { public class WidgetNameEditor extends Editor<WidgetName> {
static final WidgetName EMPTY_WIDGET_NAME = new WidgetName(StringUtils.EMPTY);
private FilterComboBox<WidgetName> comb; private FilterComboBox<WidgetName> comb;
@ -79,7 +82,8 @@ public class WidgetNameEditor extends Editor<WidgetName> {
@Override @Override
public WidgetName getValue() { public WidgetName getValue() {
return (WidgetName) comb.getSelectedItem(); WidgetName widgetName = (WidgetName) comb.getSelectedItem();
return widgetName == null ? EMPTY_WIDGET_NAME : widgetName;
} }
@Override @Override

70
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -1,15 +1,40 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.common.report.ReportState;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector;
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe;
import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceClient;
import javax.swing.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/** /**
* 根据配置生成运行环境 * 根据配置生成运行环境
*/ */
public class DesignerWorkspaceGenerator { public class DesignerWorkspaceGenerator {
public static Workspace generate(DesignerWorkspaceInfo config) throws Exception { private static final int WAIT_FREQ = 60;
private static ExecutorService service = Executors.newCachedThreadPool(
new NamedThreadFactory("DesignerWorkspaceGenerator"));
public static Workspace generate(final DesignerWorkspaceInfo config) throws Exception {
if (config == null || config.getType() == null) { if (config == null || config.getType() == null) {
return null; return null;
@ -22,7 +47,19 @@ public class DesignerWorkspaceGenerator {
break; break;
} }
case Remote: { case Remote: {
WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); Future<WorkspaceClient> future = service.submit(new Callable<WorkspaceClient>() {
@Override
public WorkspaceClient call() throws Exception {
return WorkContext.getConnector().connect(config.getConnection());
}
});
WorkspaceClient client = null;
try {
client = future.get(WAIT_FREQ, TimeUnit.SECONDS);
} catch (TimeoutException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
RemoteHandler.handle(config);
}
if (client != null) { if (client != null) {
workspace = new RemoteWorkspace(client, config.getConnection()); workspace = new RemoteWorkspace(client, config.getConnection());
} }
@ -31,4 +68,33 @@ public class DesignerWorkspaceGenerator {
} }
return workspace; return workspace;
} }
enum RemoteHandler {
SELF;
public static void handle(DesignerWorkspaceInfo config) {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue()));
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(),
DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(),
StringUtils.EMPTY);
int result = FineJOptionPane.showOptionDialog(null,
Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
IOUtils.readIcon("com/fr/design/images/error/error2.png"),
new Object[] {Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Wait"), Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Switch")},
null);
if (result == JOptionPane.YES_OPTION) {
try {
generate(config);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}
public static void stop() {
service.shutdown();
}
} }

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

@ -10,6 +10,9 @@ public interface DesignerWorkspaceInfo extends XMLable {
String getPath(); String getPath();
//获取提醒时间,用于判断是否做服务检测
String getRemindTime();
WorkspaceConnectionInfo getConnection(); WorkspaceConnectionInfo getConnection();
boolean checkValid(); boolean checkValid();

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

@ -43,6 +43,11 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
return path; return path;
} }
@Override
public String getRemindTime() {
return null;
}
@Override @Override
public WorkspaceConnectionInfo getConnection() { public WorkspaceConnectionInfo getConnection() {
return null; return null;

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

@ -13,6 +13,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private String name; private String name;
private String remindTime;
private WorkspaceConnectionInfo connection; private WorkspaceConnectionInfo connection;
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) {
@ -45,11 +47,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
return connection; return connection;
} }
public void setRemindTime(String remindTime){
this.remindTime = remindTime;
}
@Override
public String getRemindTime(){
return remindTime;
}
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY);
} }
if (reader.isChildNode()) { if (reader.isChildNode()) {
String tagName = reader.getTagName(); String tagName = reader.getTagName();
@ -69,6 +81,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name); writer.attr("name", name);
writer.attr("remindTime", remindTime);
if (this.connection != null) { if (this.connection != null) {
writer.startTAG("Connection"); writer.startTAG("Connection");
writer.attr("url", connection.getUrl()); writer.attr("url", connection.getUrl());

17
designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java vendored

@ -1,8 +1,10 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.cluster.engine.remote.ClusterOperator;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.base.operator.common.CommonOperator;
import com.fr.rpc.ExceptionHandler; import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
@ -48,9 +50,13 @@ public class RemoteWorkspace implements Workspace {
@Override @Override
public boolean isWarDeploy() { public boolean isWarDeploy() {
return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler<Boolean>() {
@Override
public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
return false; return false;
} }
}).isWarDeploy();
}
@Override @Override
public boolean isLocal() { public boolean isLocal() {
@ -73,7 +79,12 @@ public class RemoteWorkspace implements Workspace {
@Override @Override
public boolean isCluster() { public boolean isCluster() {
return FineClusterConfig.getInstance().isCluster(); return WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler<Boolean>() {
@Override
public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
return false;
}
}).isCluster();
} }
@Override @Override

11
designer-base/src/main/java/com/fr/design/event/RemoveListener.java

@ -0,0 +1,11 @@
package com.fr.design.event;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/19
*/
public interface RemoveListener {
void doRemoveAction();
}

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

@ -1,10 +1,10 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallFromDiskCallback;
import com.fr.design.extra.exe.callback.InstallOnlineCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.exe.callback.ModifyStatusCallback; import com.fr.design.extra.exe.callback.ModifyStatusCallback;
import com.fr.design.extra.exe.callback.UninstallPluginCallback; import com.fr.design.extra.exe.callback.UninstallPluginCallback;
import com.fr.design.extra.exe.callback.UpdateFromDiskCallback; import com.fr.design.extra.exe.callback.UpdateFromDiskCallback;
@ -13,6 +13,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
@ -25,9 +26,9 @@ import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.SwingUtilities;
import java.io.File; import java.io.File;
import java.net.HttpURLConnection;
import java.util.List; import java.util.List;
@ -110,13 +111,18 @@ public class PluginOperateUtils {
public static String getRecommendPlugins() { public static String getRecommendPlugins() {
String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.feature"); String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.feature");
JSONArray resultArray = JSONArray.create(); JSONArray resultArray = JSONArray.create();
if (StringUtils.isBlank(plistUrl)) {
return resultArray.toString();
}
try { try {
HttpClient httpClient = new HttpClient(plistUrl); HttpClient httpClient = new HttpClient(plistUrl);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
String result = httpClient.getResponseText(); String result = httpClient.getResponseText();
JSONArray jsonArray = new JSONArray(result); JSONArray jsonArray = new JSONArray(result);
resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); resultArray = PluginUtils.filterPluginsFromVersion(jsonArray);
} catch (Exception e) { }
FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (JSONException e) {
FineLoggerFactory.getLogger().info(e.getMessage(), e);
} }
return resultArray.toString(); return resultArray.toString();
} }

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

@ -2,6 +2,7 @@ package com.fr.design.extra;
import com.fr.base.TemplateUtils; import com.fr.base.TemplateUtils;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
@ -12,8 +13,8 @@ import com.fr.plugin.basic.version.Version;
import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.basic.version.VersionIntervalFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.error.PluginBaseErrorCode; import com.fr.plugin.error.PluginBaseErrorCode;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
@ -21,11 +22,12 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JOptionPane; import javax.swing.*;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -46,8 +48,7 @@ public class PluginUtils {
public static PluginMarker createPluginMarker(String pluginInfo) { public static PluginMarker createPluginMarker(String pluginInfo) {
//todo 判空 //todo 判空
String[] plugin = pluginInfo.split("_"); String[] plugin = pluginInfo.split("_");
PluginMarker pluginMarker = PluginMarker.create(plugin[0], plugin[1]); return PluginMarker.create(plugin[0], plugin[1]);
return pluginMarker;
} }
public static JSONObject getLatestPluginInfo(String pluginID) throws Exception { public static JSONObject getLatestPluginInfo(String pluginID) throws Exception {
@ -90,7 +91,11 @@ public class PluginUtils {
InputStream reader = null; InputStream reader = null;
FileOutputStream writer = null; FileOutputStream writer = null;
try { try {
HttpClient httpClient = new HttpClient(getDownloadPath(id)); String downloadPath = getDownloadPath(id);
if (StringUtils.isBlank(downloadPath)) {
throw new PluginVerifyException(Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error"));
}
HttpClient httpClient = new HttpClient(downloadPath);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
int totalSize = httpClient.getContentLength(); int totalSize = httpClient.getContentLength();
reader = httpClient.getResponseStream(); reader = httpClient.getResponseStream();
@ -108,12 +113,12 @@ public class PluginUtils {
p.process(totalBytesRead / (double) totalSize); p.process(totalBytesRead / (double) totalSize);
} }
} else { } else {
throw new com.fr.plugin.PluginVerifyException(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error")); throw new PluginVerifyException(Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error"));
} }
} catch (PluginVerifyException e) { } catch (PluginVerifyException e) {
FineJOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); FineJOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false; return false;
} catch (Exception e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;
} finally { } finally {
@ -136,19 +141,27 @@ public class PluginUtils {
} }
} }
private static String getDownloadPath(String id) throws Exception { private static String getDownloadPath(String id) {
HashMap<String, String> map = new HashMap<String, String>(); String url = CloudCenter.getInstance().acquireUrlByKind("shop.script.download");
map.put("id", id); if (StringUtils.isBlank(url)) {
HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("shop.script.download")+ "?" + FR_VERSION + "=" + ProductConstants.VERSION); return StringUtils.EMPTY;
}
HttpClient httpClient = new HttpClient(url + "?" + FR_VERSION + "=" + ProductConstants.VERSION);
httpClient.asGet(); httpClient.asGet();
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
String resText = httpClient.getResponseText(); String resText = httpClient.getResponseText();
JSONObject resultJSONObject = new JSONObject(resText); JSONObject resultJSONObject = new JSONObject(resText);
String scriptUrl = resultJSONObject.optString("result"); String scriptUrl = resultJSONObject.optString("result");
String charSet = EncodeConstants.ENCODING_UTF_8; String charSet = EncodeConstants.ENCODING_UTF_8;
try {
scriptUrl = URLDecoder.decode(URLDecoder.decode(scriptUrl, charSet), charSet); scriptUrl = URLDecoder.decode(URLDecoder.decode(scriptUrl, charSet), charSet);
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return scriptUrl; return scriptUrl;
} }
return StringUtils.EMPTY;
}
public static boolean isPluginMatch(PluginView pluginView, String text) { public static boolean isPluginMatch(PluginView pluginView, String text) {
return StringUtils.contains(pluginView.getID(), text) return StringUtils.contains(pluginView.getID(), text)
@ -219,9 +232,10 @@ public class PluginUtils {
/** /**
* 在不同设计器版本下展示不同插件 * 在不同设计器版本下展示不同插件
*
* @return 插件 * @return 插件
*/ */
public static JSONArray filterPluginsFromVersion(JSONArray oriJSONArray) throws Exception{ public static JSONArray filterPluginsFromVersion(JSONArray oriJSONArray) {
JSONArray resultJSONArray = JSONArray.create(); JSONArray resultJSONArray = JSONArray.create();
for (int i = 0; i < oriJSONArray.length(); i++) { for (int i = 0; i < oriJSONArray.length(); i++) {
JSONObject jo = oriJSONArray.getJSONObject(i); JSONObject jo = oriJSONArray.getJSONObject(i);

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

@ -75,7 +75,7 @@ public class WebViewDlgHelper {
} }
return; return;
} }
String jar_version = PluginStoreConstants.getInstance().getProps(ENV_VERSION, StringUtils.EMPTY); String jar_version = PluginStoreConstants.getProps(ENV_VERSION, StringUtils.EMPTY);
if (ComparatorUtils.equals(jar_version, ProductConstants.VERSION)) { if (ComparatorUtils.equals(jar_version, ProductConstants.VERSION)) {
updateShopScripts(SHOP_SCRIPTS); updateShopScripts(SHOP_SCRIPTS);
showPluginDlg(); showPluginDlg();
@ -297,7 +297,7 @@ public class WebViewDlgHelper {
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update"); String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update");
if (url != null) { if (url != null) {
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getInstance().getProps("VERSION")); String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getProps("VERSION"));
JSONObject resultJSONObject = new JSONObject(text); JSONObject resultJSONObject = new JSONObject(text);
String isLatest = resultJSONObject.optString("result"); String isLatest = resultJSONObject.optString("result");
if (!ComparatorUtils.equals(isLatest, LATEST)) { if (!ComparatorUtils.equals(isLatest, LATEST)) {

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

@ -4,6 +4,7 @@ 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.HttpClient;
import com.fr.stable.StringUtils;
/** /**
* Created by vito on 16/5/16. * Created by vito on 16/5/16.
@ -28,7 +29,7 @@ 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"); String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.category");
if (url != null) { if (StringUtils.isNotEmpty(url)) {
HttpClient httpClient = new HttpClient(url); HttpClient httpClient = new HttpClient(url);
result = httpClient.getResponseText(); result = httpClient.getResponseText();
} else { } else {

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

@ -52,7 +52,7 @@ public class GetPluginFromStoreExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.plist");
boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope); boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope);
if (getRecommend) { if (getRecommend) {
result = PluginOperateUtils.getRecommendPlugins(); result = PluginOperateUtils.getRecommendPlugins();
@ -61,7 +61,7 @@ public class GetPluginFromStoreExecutor implements Executor {
if (StringUtils.isNotBlank(plistUrl)) { if (StringUtils.isNotBlank(plistUrl)) {
StringBuilder url = new StringBuilder(); StringBuilder url = new StringBuilder();
url.append(plistUrl); url.append(plistUrl).append("?");
PluginOperateUtils.dealParams(url, category, seller, fee, scope); PluginOperateUtils.dealParams(url, category, seller, fee, scope);
try { try {
HttpClient httpClient = new HttpClient(url.toString()); HttpClient httpClient = new HttpClient(url.toString());

10
designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java

@ -14,8 +14,8 @@ import com.fr.stable.StringUtils;
* Created by vito on 16/4/18. * Created by vito on 16/4/18.
*/ */
public class SearchOnlineExecutor implements Executor { public class SearchOnlineExecutor implements Executor {
private String result = StringUtils.EMPTY; private String result = JSONArray.create().toString();
private String keyword; private final String keyword;
public SearchOnlineExecutor(String keyword) { public SearchOnlineExecutor(String keyword) {
this.keyword = keyword; this.keyword = keyword;
@ -42,7 +42,11 @@ public class SearchOnlineExecutor implements Executor {
result = PluginOperateUtils.getRecommendPlugins(); result = PluginOperateUtils.getRecommendPlugins();
return; return;
} }
HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("shop.plugin.store") + "&keyword=" + keyword); String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.store");
if (StringUtils.isEmpty(url)) {
return;
}
HttpClient httpClient = new HttpClient(url + "&keyword=" + keyword);
httpClient.asGet(); httpClient.asGet();
String responseText = httpClient.getResponseText(); String responseText = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(responseText); JSONObject jsonObject = new JSONObject(responseText);

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

@ -2,6 +2,7 @@ package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
@ -178,15 +179,28 @@ public class HistoryTemplateListCache implements CallbackEvent {
* @return 位置 * @return 位置
*/ */
public int contains(JTemplate<?, ?> jt) { public int contains(JTemplate<?, ?> jt) {
return contains(jt, null);
}
public int contains(FILE file) {
return contains(null, file);
}
private int contains(JTemplate jt, FILE file) {
FILE item = null;
if (jt != null) {
item = jt.getEditingFILE();
} else {
item = file;
}
for (int i = 0; i < historyList.size(); i++) { for (int i = 0; i < historyList.size(); i++) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) { if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), item)) {
return i; return i;
} }
} }
return -1; return -1;
} }
/** /**
* 判断是否打开过该模板 * 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板 * 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板
@ -371,9 +385,14 @@ public class HistoryTemplateListCache implements CallbackEvent {
historyList.set(i, template); historyList.set(i, template);
// 替换当前正在编辑的模板,使用添加并激活的方式,以便使用统一的入口来处理监听事件 // 替换当前正在编辑的模板,使用添加并激活的方式,以便使用统一的入口来处理监听事件
if (isCurrentEditingFile(template.getPath())) { if (isCurrentEditingFile(template.getPath())) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template); loadCurrentTemplate(template);
setCurrentEditingTemplate(template); }
FineLoggerFactory.getLogger().info("Env Change Current Editing Template."); } else {
// 当模板为空时 说明是一个新建的未保存模板 但是内存中保存了该模板 可以从中获取
JTemplate jt = historyList.get(i);
// 另外如果该模板是正在编辑的模板,需要要激活
if (jt != null && isCurrentEditingFile(jt.getPath())) {
loadCurrentTemplate(jt);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -387,6 +406,12 @@ public class HistoryTemplateListCache implements CallbackEvent {
FineLoggerFactory.getLogger().info("Env Change Template Loaded."); FineLoggerFactory.getLogger().info("Env Change Template Loaded.");
} }
private void loadCurrentTemplate(JTemplate<?, ?> template) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template);
setCurrentEditingTemplate(template);
FineLoggerFactory.getLogger().info("Env Change Current Editing Template " + template.getTemplateName());
}
/** /**
* 重新载入当前模板刷新数据/对象 * 重新载入当前模板刷新数据/对象
*/ */
@ -394,8 +419,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
JTemplate<?, ?> jt = getCurrentEditingTemplate(); JTemplate<?, ?> jt = getCurrentEditingTemplate();
boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists();
if (access) { if (access) {
closeSelectedReport(jt); jt.refreshResource();
DesignerContext.getDesignerFrame().openTemplate(jt.getEditingFILE());
} }
} }

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

@ -2,7 +2,6 @@ package com.fr.design.formula;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -25,7 +24,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.parser.FRLexer; import com.fr.parser.FRLexer;
import com.fr.parser.FRParser; import com.fr.parser.FRParser;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.script.Expression; import com.fr.stable.script.Expression;
@ -54,7 +52,10 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.util.Locale; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/** /**
* 公式编辑面板 * 公式编辑面板
@ -413,14 +414,19 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (keyWord.length() != 0) { if (keyWord.length() != 0) {
NameAndDescription[] descriptions = FunctionConstants.ALL.getDescriptions(); NameAndDescription[] descriptions = FunctionConstants.ALL.getDescriptions();
int lengthOfDes = descriptions.length; int lengthOfDes = descriptions.length;
List<String> list = new ArrayList<>();
for (int i = 0; i < lengthOfDes; i++) { for (int i = 0; i < lengthOfDes; i++) {
NameAndDescription and = descriptions[i]; NameAndDescription and = descriptions[i];
String functionName = and.searchResult(keyWord, findDescription); String functionName = and.searchResult(keyWord, findDescription);
if (StringUtils.isNotBlank(functionName)) { if (StringUtils.isNotBlank(functionName)) {
listModel.addElement(functionName); list.add(functionName);
} }
} }
Collections.sort(list, new SimilarComparator(keyWord));
for (String name : list) {
listModel.addElement(name);
}
if (!listModel.isEmpty()) { if (!listModel.isEmpty()) {
tipsList.setSelectedIndex(0); tipsList.setSelectedIndex(0);
@ -969,6 +975,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
} }
public static class SimilarComparator implements Comparator<String> {
private String searchKey;
public SimilarComparator(String searchKey) {
this.searchKey = searchKey.toLowerCase();
}
@Override
public int compare(String o1, String o2) {
if (o1.toLowerCase().startsWith(searchKey)) {
return -1;
}
if (o2.toLowerCase().startsWith(searchKey)) {
return 1;
}
return o2.compareTo(o1);
}
}
public static class TextFolderUserObject { public static class TextFolderUserObject {
private String text; private String text;

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

@ -142,8 +142,10 @@ public class FunctionManagerPane extends BasicPane {
editorButton.setPreferredSize(new Dimension(editorButton.getPreferredSize().width, classNameTextField.getPreferredSize().height)); editorButton.setPreferredSize(new Dimension(editorButton.getPreferredSize().width, classNameTextField.getPreferredSize().height));
reportletNamePane.add(editorButton); reportletNamePane.add(editorButton);
editorButton.addActionListener(createEditorButtonActionListener()); editorButton.addActionListener(createEditorButtonActionListener());
northPane.add(GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), JPanel classNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
reportletNamePane}, FlowLayout.LEFT)); classNamePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), BorderLayout.NORTH);
classNamePane.add(reportletNamePane, BorderLayout.CENTER);
northPane.add(classNamePane);
DescriptionTextArea descriptionArea = new DescriptionTextArea(); DescriptionTextArea descriptionArea = new DescriptionTextArea();
descriptionArea.setWrapStyleWord(true); descriptionArea.setWrapStyleWord(true);
descriptionArea.setLineWrap(true); descriptionArea.setLineWrap(true);

28
designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java

@ -220,8 +220,8 @@ public class JavaEditorPane extends BasicPane {
" }\n" + " }\n" +
"\n" + "\n" +
" /**\n" + " /**\n" +
" * 获取数据集的列数\n" + " * Get the number of columns in a dataset\n" +
" * @return 数据集的列\n" + " * @return Dataset columns\n" +
" * @throws TableDataException\n" + " * @throws TableDataException\n" +
" */\n" + " */\n" +
" public int getColumnCount() throws TableDataException {\n" + " public int getColumnCount() throws TableDataException {\n" +
@ -229,9 +229,9 @@ public class JavaEditorPane extends BasicPane {
" }\n" + " }\n" +
"\n" + "\n" +
" /**\n" + " /**\n" +
" * 获取数据集指定列的列名\n" + " * Get the column name of the specified column of the dataset\n" +
" * @param columnIndex 指定列的索引\n" + " * @param columnIndex The index of the specified column\n" +
" * @return 指定列的列名\n" + " * @return The column name of the specified column\n" +
" * @throws TableDataException\n" + " * @throws TableDataException\n" +
" */\n" + " */\n" +
" public String getColumnName(int columnIndex) throws TableDataException {\n" + " public String getColumnName(int columnIndex) throws TableDataException {\n" +
@ -239,8 +239,8 @@ public class JavaEditorPane extends BasicPane {
" }\n" + " }\n" +
"\n" + "\n" +
" /**\n" + " /**\n" +
" * 获取数据集的行数\n" + " * Get the number of rows in the dataset\n" +
" * @return 数据集数据行数\n" + " * @return Dataset rows\n" +
" * @throws TableDataException\n" + " * @throws TableDataException\n" +
" */\n" + " */\n" +
" public int getRowCount() throws TableDataException {\n" + " public int getRowCount() throws TableDataException {\n" +
@ -248,10 +248,10 @@ public class JavaEditorPane extends BasicPane {
" }\n" + " }\n" +
"\n" + "\n" +
" /**\n" + " /**\n" +
" * 获取数据集指定位置上的值\n" + " * Get the value at the specified position in the dataset\n" +
" * @param rowIndex 指定的行索引\n" + " * @param rowIndex The specified row index\n" +
" * @param columnIndex 指定的列索引\n" + " * @param columnIndex The specified column index\n" +
" * @return 指定位置的值\n" + " * @return The value of the specified location\n" +
" */\n" + " */\n" +
" public Object getValueAt(int rowIndex, int columnIndex) {\n" + " public Object getValueAt(int rowIndex, int columnIndex) {\n" +
" return null;\n" + " return null;\n" +
@ -263,12 +263,12 @@ public class JavaEditorPane extends BasicPane {
"import com.fr.script.AbstractFunction;\n" + "import com.fr.script.AbstractFunction;\n" +
"\n" + "\n" +
"/**\n" + "/**\n" +
" * 自定义函数\n" + " * Custom function\n" +
" */\n" + " */\n" +
"public class CustomFun extends AbstractFunction {\n" + "public class CustomFun extends AbstractFunction {\n" +
" /**\n" + " /**\n" +
" * @param args 函数的参数,是经过了算子处理了其中特殊参数的\n" + " * @param args The parameters of the function are processed by calculator with special parameters\n" +
" * @return 经过函数处理的值,用于参与最终计算\n" + " * @return The value processed by the function is used to participate in the final calculation\n" +
" */\n" + " */\n" +
" public Object run(Object[] args) {\n" + " public Object run(Object[] args) {\n" +
" return null;\n" + " return null;\n" +

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

@ -0,0 +1,21 @@
package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.fun.mark.Mutable;
/**
* @author yaohwu
* created by yaohwu at 2020/4/26 15:50
*/
public interface CellExpandAttrPanelProvider extends Mutable {
String MARK_STRING = "CellExpandAttrPanelProvider";
int CURRENT_LEVEL = 1;
/**
* @return 创建单元格属性-扩展设置中的额外面板
*/
BasicBeanPane<TemplateCellElement> createPanel();
}

45
designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java

@ -0,0 +1,45 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
/**
* created by Harrison on 2020/05/14
**/
public interface ClipboardHandlerProvider<T> extends Mutable {
String XML_TAG = "ClipboardHandlerProvider";
int CURRENT_LEVEL = 1;
/**
* 剪切
*
* @param selection 选中
* @return 处理后的内容
*/
T cut(T selection);
/**
* 复制
*
* @param selection 选中
* @return 处理后的内容
*/
T copy(T selection);
/**
* 粘贴
*
* @param selection 选中
* @return 处理后的内容
*/
T paste(T selection);
/**
* 支持的类型
*
* @param selection 内容
* @return 是否
*/
boolean support(Object selection);
}

57
designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java

@ -0,0 +1,57 @@
package com.fr.design.fun;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.DockingView;
import com.fr.stable.fun.mark.Immutable;
import javax.swing.JPanel;
/**
* 组件库面板处理器
*
* created by Harrison on 2020/03/16
**/
public interface ComponentLibraryPaneProcessor extends Immutable {
String XML_TAG = "ComponentLibraryPaneProcessor";
int CURRENT_LEVEL = 1;
/**
* 创建展示面板
*
* @param isEdit 是否可以编辑
* @return 展示面板
*/
UIScrollPane createShowPanel(boolean isEdit);
/**
* 创建菜单的上部面板
*
* @return 面板
*/
JPanel createMenuNorthPane();
/**
* 创建复选框
*
* @return 复选框
*/
UIComboBox createMenuComBox();
void parentView(DockingView dockingView);
/**
* 父面板
*
* @param panel 面板
*/
void parentPane(JPanel panel);
/**
* 创建完成
*/
void complete();
}

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

@ -0,0 +1,23 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
import com.fr.start.BaseDesigner;
/**
* 设计器启动类替换接口
*
* @author hades
* @version 10.0
* Created by hades on 2020/5/7
*/
public interface DesignerStartClassProcessor extends Mutable {
String MARK_STRING = "DesignerStartClassProcessor";
int CURRENT_LEVEL = 1;
Class<? extends BaseDesigner> transform();
}

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

@ -0,0 +1,43 @@
package com.fr.design.fun;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.ShortCut;
import com.fr.stable.fun.mark.Immutable;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
/**
* Created by kerry on 2020-04-09
* 临时接口后续自适应内置后删除
*/
public interface FormAdaptiveConfigUIProcessor extends Immutable {
String MARK_STRING = "FormAdaptiveConfigUIProcessor";
int CURRENT_LEVEL = 1;
/**
* 获取表单自适应配置菜单
* @return 表单自适应配置菜单
*/
ShortCut getConfigShortCut(JTemplate jTemplate);
/**
* 绘制自适应下报表块在表单界面中显示图片
* @param size 绘制尺寸
* @param elementCasePane 报表块内容对象
* @return 自适应下报表块在表单界面中显示的图片
*/
BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane);
/**
* 获取新自适应下字体显示的dpi
* @return dpi
*/
int fontResolution();
}

25
designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java

@ -0,0 +1,25 @@
package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.stable.fun.mark.Mutable;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public interface MobileTemplateStyleProvider extends Mutable {
String XML_TAG = "MobileTemplateStyleProvider";
int CURRENT_LEVEL = 1;
Class<? extends MobileTemplateStyle> classFroMobileTemplateStyle();
Class<? extends BasicBeanPane<MobileTemplateStyle>> classFroMobileTemplateStyleAppearance();
String displayName();
}

39
designer-base/src/main/java/com/fr/design/fun/ReportLengthUNITProvider.java

@ -0,0 +1,39 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.unit.UNIT;
/**
* Created by kerry on 2020-04-09
*/
public interface ReportLengthUNITProvider extends Mutable {
String MARK_STRING = "ReportLengthUNITProvider";
int CURRENT_LEVEL = 1;
/**
* 标尺单位显示字符
* @return 标尺单位字符
*/
String unitText();
/**
* 标尺单位类型(之前是将int类型的值直接保存在数据库里面的)
* @return 返回标尺单位类型
*/
int unitType();
/**
* UNIT转标尺单位值
* @param value UNIT
* @return 标尺单位值
*/
float unit2Value4Scale(UNIT value);
/**
* 标尺单位值转UNIT
* @param value 标尺单位值
* @return UNIT
*/
UNIT float2UNIT(float value);
}

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

@ -0,0 +1,39 @@
package com.fr.design.fun.impl;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.CellExpandAttrPanelProvider;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.fun.mark.API;
/**
* @author yaohwu
* created by yaohwu at 2020/4/26 16:08
*/
@API(level = CellExpandAttrPanelProvider.CURRENT_LEVEL)
public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelProvider {
/**
* 当前接口的API等级,用于判断是否需要升级插件
*
* @return API等级
*/
@Override
public int currentAPILevel() {
return CellExpandAttrPanelProvider.CURRENT_LEVEL;
}
/**
* 获取当前provider的标记可以使用类路径保证唯一以避免provider的重复加载
*
* @return 当前provider的标记
*/
@Override
public String mark4Provider() {
return null;
}
@Override
public BasicBeanPane<TemplateCellElement> createPanel() {
return null;
}
}

17
designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java

@ -0,0 +1,17 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* created by Harrison on 2020/05/14
**/
@API(level = ClipboardHandlerProvider.CURRENT_LEVEL)
public abstract class AbstractClipboardHandlerProvider<T> extends AbstractProvider implements ClipboardHandlerProvider<T> {
@Override
public int currentAPILevel() {
return ClipboardHandlerProvider.CURRENT_LEVEL;
}
}

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

@ -0,0 +1,23 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.DesignerStartClassProcessor;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/5/7
*/
@API(level = DesignerStartClassProcessor.CURRENT_LEVEL)
public abstract class AbstractDesignerStartClassProcessorProcessor implements DesignerStartClassProcessor {
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

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

@ -0,0 +1,23 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.FormAdaptiveConfigUIProcessor;
import com.fr.stable.fun.mark.API;
/**
* Created by kerry on 2020-04-09
*/
@API(level = FormAdaptiveConfigUIProcessor.CURRENT_LEVEL)
public abstract class AbstractFormAdaptiveConfigUIProcessor implements FormAdaptiveConfigUIProcessor {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

25
designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java

@ -0,0 +1,25 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.MobileTemplateStyleProvider;
import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL)
public abstract class AbstractMobileTemplateStyleProvider extends AbstractProvider implements MobileTemplateStyleProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
}

42
designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportLengthUNITProvider.java

@ -0,0 +1,42 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
import com.fr.stable.unit.UNIT;
/**
* Created by kerry on 2020-04-09
*/
@API(level = ReportLengthUNITProvider.CURRENT_LEVEL)
public abstract class AbstractReportLengthUNITProvider extends AbstractProvider implements ReportLengthUNITProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String unitText() {
return StringUtils.EMPTY;
}
@Override
public int unitType() {
return 0;
}
@Override
public float unit2Value4Scale(UNIT value) {
return 0;
}
@Override
public UNIT float2UNIT(float value) {
return UNIT.ZERO;
}
}

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

@ -29,11 +29,11 @@ import com.fr.design.gui.itoolbar.UIToolBarBorder;
import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI; import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI;
import com.fr.design.gui.itooltip.UIToolTipBorder; import com.fr.design.gui.itooltip.UIToolTipBorder;
import com.fr.design.gui.itree.UITreeUI; import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import javax.swing.ImageIcon; import javax.swing.*;
import javax.swing.UIDefaults;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.plaf.BorderUIResource; import javax.swing.plaf.BorderUIResource;
@ -52,6 +52,12 @@ import java.net.URL;
*/ */
public class UILookAndFeel extends MetalLookAndFeel { public class UILookAndFeel extends MetalLookAndFeel {
static {
UIManager.put("ProgressMonitor.progressText", Toolkit.i18nText("Fine-Design_Basic_ProgressBar_Title"));
UIManager.put("OptionPane.cancelButtonText", Toolkit.i18nText("Fine-Design_Basic_Cancel"));
}
public static boolean CONTROL_PANEL_INSTANTIATED = false; public static boolean CONTROL_PANEL_INSTANTIATED = false;

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

@ -1,10 +1,13 @@
package com.fr.design.gui.controlpane; package com.fr.design.gui.controlpane;
import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -99,6 +102,15 @@ class JControlUpdatePane extends JPanel {
if (pane != null && pane.isVisible()) { if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean(); Object bean = pane.updateBean();
try {
if (bean instanceof RemoteDesignerWorkspaceInfo) {
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName());
String remindTime = info.getRemindTime();
((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime);
}
}catch (Exception e){
FineLoggerFactory.getLogger().info("remindTime is not exist");
}
if (i < creators.length) { if (i < creators.length) {
creators[i].saveUpdatedBean(elEditing, bean); creators[i].saveUpdatedBean(elEditing, bean);
} }

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

@ -7,6 +7,7 @@ import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.present.dict.TableDataDictPane; import com.fr.design.present.dict.TableDataDictPane;
import com.fr.form.ui.tree.LayerConfig; import com.fr.form.ui.tree.LayerConfig;
import com.fr.form.ui.tree.LayerDependence; import com.fr.form.ui.tree.LayerDependence;
import com.fr.stable.StringUtils;
import java.awt.*; import java.awt.*;
import java.util.*; import java.util.*;
@ -73,13 +74,19 @@ public class LayerDataConfigPane extends BasicBeanPane<LayerConfig> {
if (wrapper != null) { if (wrapper != null) {
columnNames = wrapper.calculateColumnNameList(); columnNames = wrapper.calculateColumnNameList();
} else { } else {
columnNames = new ArrayList<String>(); columnNames = new ArrayList<>();
} }
String viewColStr = tableDataDictPane.updateBean().getValueColumnName();
String modelColStr = tableDataDictPane.updateBean().getKeyColumnName();
TableDataDictionary dictionary = tableDataDictPane.updateBean(); TableDataDictionary dictionary = tableDataDictPane.updateBean();
String viewColStr = dictionary.getValueColumnName();
String modelColStr = dictionary.getKeyColumnName();
int viewCol = columnNames.indexOf(viewColStr); int viewCol = columnNames.indexOf(viewColStr);
int modelCol = columnNames.indexOf(modelColStr); int modelCol = columnNames.indexOf(modelColStr);
if (StringUtils.EMPTY.equals(viewColStr)) {
viewCol = dictionary.getValueColumnIndex();
}
if (StringUtils.EMPTY.equals(modelColStr)) {
modelCol = dictionary.getKeyColumnIndex();
}
//将数据设置到当前正在修改的layerData中 //将数据设置到当前正在修改的layerData中
this.layerConfig.setDictionary(dictionary); this.layerConfig.setDictionary(dictionary);
this.layerConfig.setModelColumn(modelCol); this.layerConfig.setModelColumn(modelCol);

24
designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java

@ -24,10 +24,10 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver { public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver {
private static final int SIZE = 16; public static final int SIZE = 16;
private static final int SIZE_2 = 2; public static final int SIZE_2 = 2;
private static final int SIZE_4 = 4; public static final int SIZE_4 = 4;
private static final int SIZE_6 = 6; public static final int SIZE_6 = 6;
private static final int POPUP_MENU_SHIFT = -70; private static final int POPUP_MENU_SHIFT = -70;
private Color color = Color.BLACK; private Color color = Color.BLACK;
private ColorControlWindow popupWin; private ColorControlWindow popupWin;
@ -53,6 +53,14 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
iniListener(); iniListener();
} }
public ColorControlWindow getPopupWin() {
return popupWin;
}
public void setPopupWin(ColorControlWindow popupWin) {
this.popupWin = popupWin;
}
private void iniListener() { private void iniListener() {
if (shouldResponseChangeListener()) { if (shouldResponseChangeListener()) {
this.addColorChangeListener(new ChangeListener() { this.addColorChangeListener(new ChangeListener() {
@ -103,8 +111,12 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
if (ComparatorUtils.equals(this.color, color)) { if (ComparatorUtils.equals(this.color, color)) {
return; return;
} }
Color oldColor = this.color;
this.color = color; this.color = color;
checkColorChange(oldColor, this.color);
}
protected void checkColorChange(Color oldColor, Color newColor) {
hidePopupMenu(); hidePopupMenu();
fireColorStateChanged(); fireColorStateChanged();
} }
@ -139,7 +151,7 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
repaint(); repaint();
} }
private ColorControlWindow getColorControlWindow() { protected ColorControlWindow getColorControlWindow() {
//find parant. //find parant.
if (this.popupWin == null) { if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(UIColorButton.this) { this.popupWin = new ColorControlWindow(UIColorButton.this) {

38
designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java

@ -0,0 +1,38 @@
package com.fr.design.gui.ibutton;
import com.fr.chart.base.ChartConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.style.color.ColorControlWindow;
import com.fr.design.style.color.ColorControlWindowWithAuto;
import com.fr.general.ComparatorUtils;
import java.awt.Color;
public class UIColorButtonWithAuto extends UIColorButton {
protected void checkColorChange(Color oldColor, Color newColor) {
if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) {
setIcon(UIConstants.FONT_ICON);
}
if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) {
setIcon(UIConstants.AUTO_FONT_ICON);
}
super.checkColorChange(oldColor, newColor);
}
protected ColorControlWindow getColorControlWindow() {
if (getPopupWin() == null) {
ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) {
protected void colorChanged() {
UIColorButtonWithAuto.this.setColor(this.getColor());
}
};
setPopupWin(colorControlWindowWithAuto);
}
return getPopupWin();
}
}

16
designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java

@ -22,6 +22,8 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
private String radioButtonName = StringUtils.EMPTY; private String radioButtonName = StringUtils.EMPTY;
private boolean markMnemonic = true;
public UIRadioButton() { public UIRadioButton() {
super(); super();
initListener(); initListener();
@ -58,6 +60,13 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam
initComponent(); initComponent();
} }
public UIRadioButton(String text, boolean selected, boolean markMnemonic) {
super(text, selected);
initListener();
initComponent();
this.markMnemonic = markMnemonic;
}
public UIRadioButton(String text, Icon icon) { public UIRadioButton(String text, Icon icon) {
super(text, icon); super(text, icon);
initListener(); initListener();
@ -70,6 +79,13 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam
initListener(); initListener();
} }
public void setMnemonic(char mnemonic) {
super.setMnemonic(mnemonic);
if (!markMnemonic) {
setDisplayedMnemonicIndex(-1);
}
}
private void initListener() { private void initListener() {
if (shouldResponseChangeListener()) { if (shouldResponseChangeListener()) {
this.addItemListener(new ItemListener() { this.addItemListener(new ItemListener() {

121
designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButtonUI.java

@ -5,9 +5,12 @@ import com.fr.design.utils.ThemeUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.plaf.metal.MetalRadioButtonUI; import javax.swing.plaf.metal.MetalRadioButtonUI;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import javax.swing.text.View;
import sun.swing.SwingUtilities2;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -84,6 +87,124 @@ public class UIRadioButtonUI extends MetalRadioButtonUI {
return radioButton; return radioButton;
} }
// ********************************
// Paint Methods
// ********************************
public synchronized void paint(Graphics g, JComponent c) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
Dimension size = c.getSize();
int w = size.width;
int h = size.height;
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f);
Rectangle viewRect = new Rectangle(size);
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Insets i = c.getInsets();
viewRect.x += i.left;
viewRect.y += i.top;
viewRect.width -= (i.right + viewRect.x);
viewRect.height -= (i.bottom + viewRect.y);
Icon altIcon = b.getIcon();
Icon selectedIcon = null;
Icon disabledIcon = null;
String text = SwingUtilities.layoutCompoundLabel(
c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect, b.getIconTextGap());
// fill background
if (c.isOpaque()) {
g.setColor(b.getBackground());
g.fillRect(0, 0, size.width, size.height);
}
// Paint the radio button
if (altIcon != null) {
if (!model.isEnabled()) {
if (model.isSelected()) {
altIcon = b.getDisabledSelectedIcon();
} else {
altIcon = b.getDisabledIcon();
}
} else if (model.isPressed() && model.isArmed()) {
altIcon = b.getPressedIcon();
if (altIcon == null) {
// Use selected icon
altIcon = b.getSelectedIcon();
}
} else if (model.isSelected()) {
if (b.isRolloverEnabled() && model.isRollover()) {
altIcon = b.getRolloverSelectedIcon();
if (altIcon == null) {
altIcon = b.getSelectedIcon();
}
} else {
altIcon = b.getSelectedIcon();
}
} else if (b.isRolloverEnabled() && model.isRollover()) {
altIcon = b.getRolloverIcon();
}
if (altIcon == null) {
altIcon = b.getIcon();
}
altIcon.paintIcon(c, g, iconRect.x, iconRect.y);
} else {
getDefaultIcon().paintIcon(c, g, iconRect.x, iconRect.y);
}
// Draw the Text
if (text != null) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
v.paint(g, textRect);
} else {
int mnemIndex = b.getDisplayedMnemonicIndex();
if (model.isEnabled()) {
// *** paint the text normally
g.setColor(b.getForeground());
} else {
// *** paint the text disabled
g.setColor(getDisabledTextColor());
}
if (markMnemonic(text, mnemIndex)) {
SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
mnemIndex, textRect.x, textRect.y + fm.getAscent());
} else {
SwingUtilities2.drawString(c, g, text, textRect.x, textRect.y + fm.getAscent());
}
}
if (b.hasFocus() && b.isFocusPainted() &&
textRect.width > 0 && textRect.height > 0) {
paintFocus(g, textRect, size);
}
}
}
/**
* @param text
* @param mnemIndex 助记符在text中的索引
* @return true:需要给助记符画一个下划线
*/
private boolean markMnemonic(String text, int mnemIndex) {
return mnemIndex > 0 && text != null && text.length() > 0 && text.length() > mnemIndex;
}
/** /**
* Paints the focus for the radiobutton * Paints the focus for the radiobutton

16
designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java

@ -34,6 +34,7 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
private String checkboxName = ""; private String checkboxName = "";
private boolean markMnemonic = true;
public UICheckBox(String string) { public UICheckBox(String string) {
super(string); super(string);
@ -53,6 +54,13 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
initListener(); initListener();
} }
public UICheckBox(String locText, boolean b, boolean markMnemonic) {
super(locText, b);
setUI(new UICheckBoxUI());
initListener();
this.markMnemonic=markMnemonic;
}
public UICheckBox(String text, Icon icon) { public UICheckBox(String text, Icon icon) {
super(text, icon); super(text, icon);
setUI(new UICheckBoxUI()); setUI(new UICheckBoxUI());
@ -189,14 +197,18 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
if (v != null) { if (v != null) {
v.paint(g, textRect); v.paint(g, textRect);
} else { } else {
int mnemIndex = b.getDisplayedMnemonicIndex();
if (model.isEnabled()) { if (model.isEnabled()) {
g.setColor(b.getForeground()); g.setColor(b.getForeground());
} else { } else {
g.setColor(getDisabledTextColor()); g.setColor(getDisabledTextColor());
} }
if (markMnemonic) {
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
mnemIndex, textRect.x, textRect.y + fm.getAscent()); b.getDisplayedMnemonicIndex(), textRect.x, textRect.y + fm.getAscent());
} else {
SwingUtilities2.drawString(c, g, text, textRect.x, textRect.y + fm.getAscent());
}
} }
} }
} }

61
designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -1,22 +1,14 @@
package com.fr.design.gui.icombobox; package com.fr.design.gui.icombobox;
import java.awt.BorderLayout; import com.fr.design.constants.UIConstants;
import java.awt.Color; import com.fr.design.gui.ibutton.UIButton;
import java.awt.Component; import com.fr.design.gui.ilable.UILabel;
import java.awt.Dimension; import com.fr.design.gui.itextfield.UITextField;
import java.awt.Graphics; import com.fr.design.layout.FRGUIPaneFactory;
import java.awt.Graphics2D; import com.fr.general.ComparatorUtils;
import java.awt.IllegalComponentStateException; import com.fr.general.NameObject;
import java.awt.RenderingHints; import com.fr.stable.Constants;
import java.awt.event.KeyAdapter; import com.fr.stable.StringUtils;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.util.Enumeration;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListCellRenderer;
@ -38,16 +30,23 @@ 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.util.Enumeration;
import com.fr.design.constants.UIConstants; import java.awt.BorderLayout;
import com.fr.design.gui.ibutton.UIButton; import java.awt.Color;
import com.fr.design.gui.ilable.UILabel; import java.awt.Component;
import com.fr.design.gui.itextfield.UITextField; import java.awt.Dimension;
import com.fr.design.layout.FRGUIPaneFactory; import java.awt.Graphics;
import com.fr.general.ComparatorUtils; import java.awt.Graphics2D;
import com.fr.general.NameObject; import java.awt.IllegalComponentStateException;
import com.fr.stable.Constants; import java.awt.RenderingHints;
import com.fr.stable.StringUtils; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
public class FRTreeComboBox extends UIComboBox { public class FRTreeComboBox extends UIComboBox {
@ -79,7 +78,7 @@ public class FRTreeComboBox extends UIComboBox {
boolean showRoot, boolean editable) { boolean showRoot, boolean editable) {
this.setTree(tree); this.setTree(tree);
this.tree.setCellRenderer(renderer); this.tree.setCellRenderer(renderer);
this.setEditor(new FrTreeSearchComboBoxEditor(this)); this.setEditor(createEditor());
if (!showRoot) { if (!showRoot) {
tree.expandPath(new TreePath(tree.getModel().getRoot())); tree.expandPath(new TreePath(tree.getModel().getRoot()));
tree.setRootVisible(false); tree.setRootVisible(false);
@ -101,6 +100,10 @@ public class FRTreeComboBox extends UIComboBox {
return true; return true;
} }
protected UIComboBoxEditor createEditor() {
return new FrTreeSearchComboBoxEditor(this);
}
public void setTree(JTree tree) { public void setTree(JTree tree) {
this.tree = tree; this.tree = tree;
if (tree != null) { if (tree != null) {
@ -529,7 +532,7 @@ public class FRTreeComboBox extends UIComboBox {
} }
} }
class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener {
private volatile boolean setting = false; private volatile boolean setting = false;
private FRTreeComboBox comboBox; private FRTreeComboBox comboBox;
private Object item; private Object item;

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

@ -371,6 +371,14 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
popup.setSelectedValue(map); popup.setSelectedValue(map);
} }
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
this.popup.setEnabled(enabled);
this.editor.setEnabled(enabled);
this.arrowButton.setEnabled(enabled);
}
/** /**
* 简单的测试demo * 简单的测试demo
* @param args * @param args

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

@ -91,10 +91,10 @@ public class TableViewList extends UIList {
if (refreshList != null) { if (refreshList != null) {
refreshList.cancel(true); refreshList.cancel(true);
} }
refreshList = new SwingWorker<Void, Void>() { refreshList = new SwingWorker<DefaultListModel, Void>() {
@Override @Override
protected Void doInBackground() throws Exception { protected DefaultListModel doInBackground() throws Exception {
Connection datasource = ConnectionConfig.getInstance().getConnection(databaseName); Connection datasource = ConnectionConfig.getInstance().getConnection(databaseName);
boolean status = false; boolean status = false;
int count = 3; int count = 3;
@ -106,13 +106,13 @@ public class TableViewList extends UIList {
if (!status) { if (!status) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
TableViewList.this.setModel(processDataInAnotherThread(databaseName, searchFilter, typesFilter)); return processDataInAnotherThread(databaseName, searchFilter, typesFilter);
return null;
} }
@Override
public void done() { public void done() {
try { try {
get(); TableViewList.this.setModel(get());
} catch (Exception e) { } catch (Exception e) {
if (!(e instanceof InterruptedException) && !(e instanceof CancellationException)) { if (!(e instanceof InterruptedException) && !(e instanceof CancellationException)) {
TableViewList.this.setModel(failed); TableViewList.this.setModel(failed);

2
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java

@ -235,7 +235,7 @@ public abstract class UITableModelAdapter<T extends Object> extends AbstractTabl
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int[] selectedRow = table.getSelectedRows(); int[] selectedRow = table.getSelectedRows();
if (ismultiSelected()) { if (ismultiSelected()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Multiple_Select_Warn_Text")); FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Multiple_Select_Warn_Text"));
return; return;
} }
if (table.getCellEditor() != null) { if (table.getCellEditor() != null) {

10
designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java

@ -229,6 +229,16 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
cellBorderStyle.setVerticalStyle(verticalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); cellBorderStyle.setVerticalStyle(verticalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE);
cellBorderStyle.setHorizontalColor(lineColor); cellBorderStyle.setHorizontalColor(lineColor);
cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE);
if (leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected()) {
outerToggleButton.setSelected(true);
} else {
outerToggleButton.setSelected(false);
}
if (verticalToggleButton.isSelected() && horizontalToggleButton.isSelected()) {
innerToggleButton.setSelected(true);
} else {
innerToggleButton.setSelected(false);
}
return cellBorderStyle; return cellBorderStyle;
} }

112
designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java

@ -6,6 +6,8 @@ import com.fr.base.Style;
import com.fr.base.TextFormat; import com.fr.base.TextFormat;
import com.fr.data.core.FormatField; import com.fr.data.core.FormatField;
import com.fr.data.core.FormatField.FormatContents; import com.fr.data.core.FormatField.FormatContents;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -21,6 +23,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
@ -39,17 +43,20 @@ import java.text.SimpleDateFormat;
public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver { public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver {
private static final long serialVersionUID = 724330854437726751L; private static final long serialVersionUID = 724330854437726751L;
private static final int LABLE_X = 4; private static final int LABEL_X = 4;
private static final int LABLE_Y = 18; private static final int LABEL_Y = 18;
private static final int LABLE_DELTA_WIDTH = 8; private static final int LABEL_DELTA_WIDTH = 8;
private static final int LABLE_HEIGHT = 15; //标签背景的范围 private static final int LABEL_HEIGHT = 15; //标签背景的范围
private static final int CURRENCY_FLAG_POINT = 6; private static final int CURRENCY_FLAG_POINT = 6;
private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0, 30, 0, 0); private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0, 30, 0, 0);
private static final Integer[] TYPES = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC, private static final Integer[] TYPES = new Integer[]{
FormatContents.DATE, FormatContents.TIME, FormatContents.TEXT}; FormatContents.NULL, FormatContents.NUMBER,
FormatContents.CURRENCY, FormatContents.PERCENT,
FormatContents.SCIENTIFIC, FormatContents.DATE,
FormatContents.TIME, FormatContents.TEXT};
private static final Integer[] DATETYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME,}; private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME};
private Format format; private Format format;
@ -59,9 +66,11 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
private JPanel contentPane; private JPanel contentPane;
private JPanel txtCenterPane; private JPanel txtCenterPane;
private JPanel centerPane; private JPanel centerPane;
private JPanel optionPane;
private UICheckBox roundingBox;
private JPanel formatFontPane; private JPanel formatFontPane;
private FRFontPane frFontPane; private FRFontPane frFontPane;
private boolean isRightFormate; private boolean isRightFormat;
private boolean isDate = false; private boolean isDate = false;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
@ -78,7 +87,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
protected void initComponents(Integer[] types) { protected void initComponents(Integer[] types) {
this.setLayout(new BorderLayout(0, 4)); this.setLayout(new BorderLayout(0, 4));
iniSampleLable(); initSampleLabel();
contentPane = new JPanel(new BorderLayout(0, 4)) { contentPane = new JPanel(new BorderLayout(0, 4)) {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
@ -108,7 +117,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
frFontPane = new FRFontPane(); frFontPane = new FRFontPane();
UILabel font = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT); UILabel font = new UILabel(Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT);
JPanel fontPane = new JPanel(new BorderLayout()); JPanel fontPane = new JPanel(new BorderLayout());
fontPane.add(font, BorderLayout.NORTH); fontPane.add(font, BorderLayout.NORTH);
@ -119,6 +128,22 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
// centerPane.setBorder(LEFT_BORDER); // centerPane.setBorder(LEFT_BORDER);
frFontPane.setBorder(LEFT_BORDER); frFontPane.setBorder(LEFT_BORDER);
JPanel option = new JPanel(new BorderLayout());
option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST);
roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up"));
roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0));
roundingBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
}
});
roundingBox.setGlobalName("roundingBox");
option.add(roundingBox, BorderLayout.CENTER);
optionPane = new JPanel(new CardLayout());
optionPane.add(new JPanel(), "hide");
optionPane.setPreferredSize(new Dimension(0, 0));
optionPane.add(option, "show");
Component[][] components = getComponent(fontPane, centerPane, typePane); Component[][] components = getComponent(fontPane, centerPane, typePane);
this.add(createContentPane(components), BorderLayout.CENTER); this.add(createContentPane(components), BorderLayout.CENTER);
} }
@ -136,8 +161,9 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) {
return new Component[][]{ return new Component[][]{
new Component[]{null, null}, new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane},
new Component[]{centerPane, null}, new Component[]{centerPane, null},
new Component[]{optionPane, null},
new Component[]{fontPane, frFontPane}, new Component[]{fontPane, frFontPane},
}; };
} }
@ -155,24 +181,24 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
}; };
} }
private void iniSampleLable() { private void initSampleLabel() {
Border innterborder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4);
Font tmpFont = null; String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample");
Border border = BorderFactory.createTitledBorder(innterborder, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"), TitledBorder.LEFT, 0, tmpFont, UIConstants.LINE_COLOR); Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR);
sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
int width = getWidth(); int width = getWidth();
Color orignal = g.getColor(); Color original = g.getColor();
g.setColor(getBackground()); g.setColor(getBackground());
g.fillRect(LABLE_X, LABLE_Y, width - LABLE_DELTA_WIDTH, LABLE_HEIGHT); g.fillRect(LABEL_X, LABEL_Y, width - LABEL_DELTA_WIDTH, LABEL_HEIGHT);
g.setColor(UIConstants.LINE_COLOR); g.setColor(UIConstants.LINE_COLOR);
FontMetrics cellFM = g.getFontMetrics(); FontMetrics cellFM = g.getFontMetrics();
int textWidth = cellFM.stringWidth(getText()); int textWidth = cellFM.stringWidth(getText());
GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26);
g.setColor(orignal); g.setColor(original);
} }
}; };
sampleLabel.setHorizontalAlignment(UILabel.CENTER); sampleLabel.setHorizontalAlignment(UILabel.CENTER);
@ -197,7 +223,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
* @return 标题 * @return 标题
*/ */
public String title4PopupWindow() { public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text"); return Toolkit.i18nText("Fine-Design_Report_Text");
} }
/** /**
@ -212,14 +238,11 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
if (format instanceof CoreDecimalFormat) { if (format instanceof CoreDecimalFormat) {
// check all value // check all value
String pattern = ((CoreDecimalFormat) format).toPattern(); String pattern = ((CoreDecimalFormat) format).toPattern();
boolean isCurrency1 = (pattern.length() > 0 && pattern.charAt(0) == '¤'); if (isCurrencyFormatStyle(pattern)) {
boolean isCurrency2 = (pattern.length() > 0 && pattern.charAt(0) == '$');
boolean isCurrency = isCurrency1 || isCurrency2;
boolean isCurrency4 = (pattern.length() > CURRENCY_FLAG_POINT && ComparatorUtils.equals(pattern.substring(0, CURRENCY_FLAG_POINT), "#,##0;"));
if (isCurrency || isCurrency4) {
setPatternComboBoxAndList(FormatContents.CURRENCY, pattern); setPatternComboBoxAndList(FormatContents.CURRENCY, pattern);
} else if (pattern.endsWith("%")) { } else if (pattern.indexOf("%") > 0) {
setPatternComboBoxAndList(FormatContents.PERCENT, pattern); setPatternComboBoxAndList(FormatContents.PERCENT, pattern);
this.roundingBox.setSelected(((CoreDecimalFormat) format).getRoundingMode().equals(RoundingMode.HALF_UP));
} else if (pattern.indexOf("E") > 0) { } else if (pattern.indexOf("E") > 0) {
setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern); setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern);
} else { } else {
@ -238,6 +261,17 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
} }
} }
private boolean isCurrencyFormatStyle(String pattern) {
if (pattern.length() == 0) {
return false;
}
if (pattern.charAt(0) == '¤' || pattern.charAt(0) == '$') {
return true;
}
return pattern.length() > CURRENCY_FLAG_POINT && pattern.startsWith("#,##0;");
}
/** /**
* 判断是否是数组有模式 * 判断是否是数组有模式
@ -273,9 +307,10 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
if (getFormatContents() == FormatContents.TEXT) { if (getFormatContents() == FormatContents.TEXT) {
return FormatField.getInstance().getFormat(getFormatContents(), patternString); return FormatField.getInstance().getFormat(getFormatContents(), patternString);
} }
if (isRightFormate) { if (isRightFormat) {
if (StringUtils.isNotEmpty(patternString)) { if (StringUtils.isNotEmpty(patternString)) {
return FormatField.getInstance().getFormat(getFormatContents(), patternString); RoundingMode roundingMode = roundingBox.isSelected() ? RoundingMode.HALF_UP : RoundingMode.HALF_EVEN;
return FormatField.getInstance().getFormat(getFormatContents(), patternString, roundingMode);
} }
} }
return null; return null;
@ -292,7 +327,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); this.sampleLabel.setText(FormatField.getInstance().getFormatValue());
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); this.sampleLabel.setForeground(UIManager.getColor("Label.foreground"));
try { try {
isRightFormate = true; isRightFormat = true;
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) {
return; return;
} }
@ -300,7 +335,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
} catch (Exception e) { } catch (Exception e) {
this.sampleLabel.setForeground(Color.red); this.sampleLabel.setForeground(Color.red);
this.sampleLabel.setText(e.getMessage()); this.sampleLabel.setText(e.getMessage());
isRightFormate = false; isRightFormat = false;
} }
} }
@ -331,6 +366,15 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
centerPane.setPreferredSize(new Dimension(270, 65)); centerPane.setPreferredSize(new Dimension(270, 65));
cardLayout.show(centerPane, "show"); cardLayout.show(centerPane, "show");
} }
CardLayout optionLayout = ((CardLayout) optionPane.getLayout());
if (getFormatContents() == FormatContents.PERCENT) {
optionPane.setPreferredSize(new Dimension(100, 20));
optionLayout.show(optionPane, "show");
} else {
optionPane.setPreferredSize(new Dimension(0, 0));
optionLayout.show(optionPane, "hide");
roundingBox.setSelected(false);
}
} }
} }
@ -359,7 +403,9 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
* update * update
*/ */
public Style update(Style style) { public Style update(Style style) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField") || ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")) { if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) {
return style.deriveFormat(this.update()); return style.deriveFormat(this.update());
} else { } else {
return style.deriveFRFont(this.frFontPane.update(style.getFRFont())); return style.deriveFRFont(this.frFontPane.update(style.getFRFont()));
@ -401,8 +447,8 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
this.isDate = isDate; this.isDate = isDate;
this.typeComboBox.setSelectedIndex(0); this.typeComboBox.setSelectedIndex(0);
if (isDate) { if (isDate) {
for (int i = 0; i < DATETYPES.length; i++) { for (int i = 0; i < DATE_TYPES.length; i++) {
this.typeComboBox.addItem(DATETYPES[i]); this.typeComboBox.addItem(DATE_TYPES[i]);
} }
for (int i = 0; i < TYPES.length; i++) { for (int i = 0; i < TYPES.length; i++) {
this.typeComboBox.removeItemAt(1); this.typeComboBox.removeItemAt(1);
@ -411,7 +457,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs
for (int i = 0; i < TYPES.length; i++) { for (int i = 0; i < TYPES.length; i++) {
this.typeComboBox.addItem(TYPES[i]); this.typeComboBox.addItem(TYPES[i]);
} }
for (int i = 0; i < DATETYPES.length; i++) { for (int i = 0; i < DATE_TYPES.length; i++) {
this.typeComboBox.removeItemAt(1); this.typeComboBox.removeItemAt(1);
} }
} }

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

@ -1,5 +1,6 @@
package com.fr.design.i18n; package com.fr.design.i18n;
import com.fr.design.DesignerEnvManager;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.log.MessageFormatter; import com.fr.general.log.MessageFormatter;
import com.fr.locale.DesignI18nProvider; import com.fr.locale.DesignI18nProvider;
@ -14,6 +15,11 @@ import java.util.Locale;
public class DesignI18nImpl implements DesignI18nProvider { public class DesignI18nImpl implements DesignI18nProvider {
static {
// GeneralContext上下文 存储本次启动的语言环境 直接使用DesignerEnvManager 会在设置语言环境后 不重启 立即生效 存在问题
GeneralContext.setLocale(DesignerEnvManager.getEnvManager().getLanguage());
}
private static DesignI18nImpl instance = new DesignI18nImpl(); private static DesignI18nImpl instance = new DesignI18nImpl();
public static DesignI18nImpl getInstance() { public static DesignI18nImpl getInstance() {

3
designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java

@ -2,6 +2,7 @@ package com.fr.design.javascript;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.design.data.tabledata.tabledatapane.OneListTableModel; import com.fr.design.data.tabledata.tabledatapane.OneListTableModel;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.frpane.ReportletParameterViewPane; import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableEditAction;
@ -62,7 +63,7 @@ public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> {
} }
if (tempSet.contains(list.get(i).toString())) { if (tempSet.contains(list.get(i).toString())) {
list.remove(i); list.remove(i);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
parameterChanger(list); parameterChanger(list);
return; return;
} }

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

@ -4,6 +4,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.base.clipboard.DesignerClipboard;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -62,10 +63,24 @@ public class DesignerContext {
} }
/** /**
* Gets the Clipboard. * get this custom clipboard
*/ */
public static Clipboard getClipboard(JComponent comp) { public static Clipboard getClipboard(JComponent comp) {
if (DesignerContext.clipboard == null) { if (DesignerContext.clipboard == null) {
Clipboard clipboard = getClipboard0(comp);
return new DesignerClipboard(clipboard);
}
return DesignerContext.clipboard;
}
/**
* Gets the system Clipboard.
*/
private static Clipboard getClipboard0(JComponent comp) {
Clipboard clipboard = null;
try { try {
Action transferAction = TransferHandler.getCutAction(); Action transferAction = TransferHandler.getCutAction();
Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class}); Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class});
@ -78,15 +93,13 @@ public class DesignerContext {
//这样可以保证和TextField直接的copy paste //这样可以保证和TextField直接的copy paste
try { try {
//控件的Clipboard. //控件的Clipboard.
DesignerContext.clipboard = comp.getToolkit().getSystemClipboard(); clipboard = comp.getToolkit().getSystemClipboard();
} catch (Exception exp) { } catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
DesignerContext.clipboard = new Clipboard("FR"); clipboard = new Clipboard("FR");
} }
} }
} return clipboard;
return DesignerContext.clipboard;
} }

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

@ -40,6 +40,7 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuManager; import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.os.impl.MacOsAddListenerAction;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
@ -50,16 +51,18 @@ import com.fr.file.FILEFactory;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.os.OperatingSystem;
import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.os.support.OSSupportCenter;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -314,6 +317,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// window close listener. // window close listener.
this.addWindowListeners(getFrameListeners()); this.addWindowListeners(getFrameListeners());
addMacOsListener();
this.addComponentListener(new ComponentAdapter() { this.addComponentListener(new ComponentAdapter() {
@Override @Override
@ -501,8 +506,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
image = ICODecoder.read(DesignerFrame.class image = ICODecoder.read(DesignerFrame.class
.getResourceAsStream("/com/fr/base/images/oem/logo.ico")); .getResourceAsStream("/com/fr/base/images/oem/logo.ico"));
} }
if (OperatingSystem.isMacos()) {
Class clazz = Class.forName("com.apple.eawt.Application");
BufferedImage icon = image.isEmpty() ? IOUtils.readImage("/com/fr/base/images/oem/logo.png") : image.get(image.size() - 1);
Reflect.on(Reflect.on(clazz).call("getApplication").get()).call("setDockIconImage", icon);
} else {
this.setIconImages(image); this.setIconImages(image);
} catch (IOException e) { }
} catch (IOException | ClassNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
} }
@ -515,6 +526,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
private void addMacOsListener() {
OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT);
}
protected ArrayList<WindowListener> getFrameListeners() { protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<>(); ArrayList<WindowListener> arrayList = new ArrayList<>();
@ -1086,6 +1101,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void openFile(FILE tplFile) { private void openFile(FILE tplFile) {
if (tplFile != null) {
int index = HistoryTemplateListCache.getInstance().contains(tplFile);
if (index != -1) {
JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index);
if (!(jt instanceof JVirtualTemplate)) {
jt.activeOldJTemplate();
return;
}
}
}
JTemplate jt = JTemplateFactory.createJTemplate(tplFile); JTemplate jt = JTemplateFactory.createJTemplate(tplFile);
if (jt == null) { if (jt == null) {
return; return;
@ -1095,23 +1121,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.addAndActivateJTemplate(); this.addAndActivateJTemplate();
MutilTempalteTabPane.getInstance().setTemTemplate( MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
} else {
activeTemplate(jt);
}
}
/**
* 激活指定的模板
*
* @param jt 当前报表
* @date 2014-10-14-下午6:31:23
*/
private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListCache.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListCache.getInstance().getHistoryList();
if (index != -1) {
historyList.get(index).activeJTemplate(index, jt);
} else { } else {
this.addAndActivateJTemplate(jt); this.addAndActivateJTemplate(jt);
} }
@ -1135,8 +1144,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); if (jt != null) {
DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath());
}
DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY(
WestRegionContainerPane.getInstance().getToolPaneY()); WestRegionContainerPane.getInstance().getToolPaneY());
@ -1269,4 +1280,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
progressDialog.dispose(); progressDialog.dispose();
} }
/**
* 设计器是否已经打开
*
* @return 设计器是否已经打开
*/
public boolean isDesignerOpened() {
return designerOpened;
}
} }

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

@ -684,21 +684,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
this.dispose(); this.dispose();
//模版重命名 //模版重命名
boolean success = false; boolean success = selectedOperation.rename(fnf, path, newPath);
// 提醒保存文件
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时
if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) {
int choose = saveSomeTempaltePane.saveLastOneTemplate();
if (choose != JOptionPane.CANCEL_OPTION) {
success = selectedOperation.rename(fnf, path, newPath);
}
} else {
if (saveSomeTempaltePane.showSavePane()) {
success = selectedOperation.rename(fnf, path, newPath);
}
}
if (success) { if (success) {
HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); HistoryTemplateListCache.getInstance().rename(fnf, path, newPath);

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

@ -93,10 +93,11 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected U authorityUndoState = null; protected U authorityUndoState = null;
protected T template; // 当前模板 protected T template; // 当前模板
protected TemplateProcessInfo<T> processInfo; // 模板过程的相关信息 protected TemplateProcessInfo<T> processInfo; // 模板过程的相关信息
private JComponent centerPane;
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter<T, ?> designModel; private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType; private PreviewProvider previewType;
private TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
public int resolution = ScreenResolution.getScreenResolution(); public int resolution = ScreenResolution.getScreenResolution();
public JTemplate() { public JTemplate() {
@ -123,7 +124,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.editingFILE = file; this.editingFILE = file;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
this.add(createCenterPane(), BorderLayout.CENTER); addCenterPane();
this.undoState = createUndoState(); this.undoState = createUndoState();
designModel = createDesignModel(); designModel = createDesignModel();
@ -246,19 +247,47 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
/**
* 模板关闭时
*/
public void whenClose() {
// do nothing
}
/** /**
* 刷新内部资源 * 刷新内部资源
*
* 刷新资源的同时
* CenterPane 负责监听改动
* 所以需要同步处理
*/ */
public void refreshResource() { public void refreshResource() {
try { try {
this.template = JTemplateFactory.asIOFile(this.editingFILE); this.template = JTemplateFactory.asIOFile(this.editingFILE);
setTarget(this.template); setTarget(this.template);
// 先移除旧的。
removeCenterPane();
// 加入新的
addCenterPane();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
private void addCenterPane() {
this.centerPane = createCenterPane();
this.add(centerPane, BorderLayout.CENTER);
}
private void removeCenterPane() {
JComponent centerPane = this.centerPane;
this.remove(centerPane);
}
/** /**
* 刷新容器 * 刷新容器
*/ */

17
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java

@ -5,6 +5,8 @@ import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.template.info.SendHelper; import com.fr.design.mainframe.template.info.SendHelper;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -121,10 +123,23 @@ public abstract class AbstractPointCollector<T extends AbstractPointInfo> implem
} }
} }
private File getInfoFile() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), getInfoFilePath()));
try {
if (!file.exists()) {
StableUtils.makesureFileExist(file);
}
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return file;
}
/** /**
* 获取缓存文件存放路径 * 获取缓存文件存放路径
*/ */
protected abstract File getInfoFile(); protected abstract String getInfoFilePath();
protected abstract void addIdleDayCount(); protected abstract void addIdleDayCount();
} }

9
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java

@ -11,6 +11,9 @@ public abstract class AbstractPointInfo implements BasePointInfo {
protected int idleDayCount; // 到现在为止,埋点闲置的天数 protected int idleDayCount; // 到现在为止,埋点闲置的天数
//是否是测试模板
protected boolean testTemplate;
@Override @Override
public void resetIdleDayCount() { public void resetIdleDayCount() {
this.idleDayCount = 0; this.idleDayCount = 0;
@ -38,10 +41,14 @@ public abstract class AbstractPointInfo implements BasePointInfo {
} }
} }
public void setTestTemplate(boolean testTemplate) {
this.testTemplate = testTemplate;
}
/** /**
* 是否为测试模板 * 是否为测试模板
*/ */
protected abstract boolean isTestTemplate(); public abstract boolean isTestTemplate();
/** /**
* 是否已经制作完成 * 是否已经制作完成

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

@ -1,6 +1,10 @@
package com.fr.design.mainframe.chart.info; package com.fr.design.mainframe.chart.info;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.chartx.attr.ChartProvider;
import com.fr.chartx.config.info.AbstractConfig;
import com.fr.chartx.config.info.ChartConfigInfo;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -26,10 +30,11 @@ import java.util.Map;
public class ChartInfo extends AbstractPointInfo { public class ChartInfo extends AbstractPointInfo {
public static final String XML_TAG = "ChartInfo"; public static final String XML_TAG = "ChartInfo";
private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single";
private static final String CHART_FUNCTION_URL = CloudCenter.getInstance().acquireUrlByKind("chart.info.function") + "/single";
private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap"; private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap";
private static final String ATTR_TEST_TEMPLATE = "testTemplate"; private static final String ATTR_TEST_TEMPLATE = "testTemplate";
private static final String ATTR_TEST_CHART = "testChart";
private static final String ATTR_DAY_COUNT = "day_count"; private static final String ATTR_DAY_COUNT = "day_count";
private static final String ATTR_USERNAME = "username"; private static final String ATTR_USERNAME = "username";
private static final String ATTR_UUID = "uuid"; private static final String ATTR_UUID = "uuid";
@ -44,6 +49,11 @@ public class ChartInfo extends AbstractPointInfo {
private static final String ATTR_CHART_PROPERTY_END_TIME = "chartPropertyEndTime"; private static final String ATTR_CHART_PROPERTY_END_TIME = "chartPropertyEndTime";
private static final String ATTR_JAR_TIME = "jarTime"; private static final String ATTR_JAR_TIME = "jarTime";
private static final String ATTR_VERSION = "version"; private static final String ATTR_VERSION = "version";
private static final String ATTR_USER_ID = "userId";
private static final String ATTR_FIRST_CHART_TYPE = "firstChartType";
private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount";
private static final String ATTR_IS_NEW = "isNew";
private static final String ATTR_IS_REUSE = "isReuse";
private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数 private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数
@ -53,9 +63,12 @@ public class ChartInfo extends AbstractPointInfo {
private Map<String, String> chartConsumingMap = new HashMap<>(); private Map<String, String> chartConsumingMap = new HashMap<>();
private ChartConfigInfo chartConfigInfo = new ChartConfigInfo();
private BaseBook book; private BaseBook book;
private boolean testTemplate;
private boolean testChart;
private ChartInfo() { private ChartInfo() {
} }
@ -64,6 +77,7 @@ public class ChartInfo extends AbstractPointInfo {
this.chartId = chartId; this.chartId = chartId;
this.templateId = templateId; this.templateId = templateId;
this.book = book; this.book = book;
this.testChart = true;
} }
public String getChartId() { public String getChartId() {
@ -84,36 +98,42 @@ public class ChartInfo extends AbstractPointInfo {
this.chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); this.chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId);
} }
public BaseBook getBook() { public BaseBook getBook() {
return book; return book;
} }
@Override @Override
public boolean isTestTemplate() { public boolean isTestTemplate() {
return testTemplate; return testTemplate || testChart;
} }
public void setTestTemplate(boolean testTemplate) { public void setTestTemplate(boolean testTemplate) {
this.testTemplate = testTemplate; this.testTemplate = testTemplate;
} }
public void setTestChart(boolean testChart) {
this.testChart = testChart;
}
static ChartInfo newInstanceByRead(XMLableReader reader) { static ChartInfo newInstanceByRead(XMLableReader reader) {
ChartInfo chartInfo = new ChartInfo(); ChartInfo chartInfo = new ChartInfo();
reader.readXMLObject(chartInfo); reader.readXMLObject(chartInfo);
return chartInfo; return chartInfo;
} }
public static ChartInfo newInstance(String chartId, String chartType) { public static ChartInfo newInstance(ChartProvider chartProvider) {
return newInstance(chartId, chartType, null); return newInstance(chartProvider, null, false, false);
} }
public static ChartInfo newInstance(String chartId, String chartType, String createTime) { public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse) {
HashMap<String, String> chartConsumingMap = new HashMap<>(); HashMap<String, String> chartConsumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername(); String username = MarketConfig.getInstance().getBbsUsername();
String userId = String.valueOf(MarketConfig.getInstance().getBbsUid());
String uuid = DesignerEnvManager.getEnvManager().getUUID(); String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
String chartId = chartProvider.getChartUuid();
String chartType = chartProvider.getID();
BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook(); BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook();
String templateId = book.getTemplateID(); String templateId = book.getTemplateID();
@ -138,9 +158,15 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, "");
chartConsumingMap.put(ATTR_JAR_TIME, jarTime); chartConsumingMap.put(ATTR_JAR_TIME, jarTime);
chartConsumingMap.put(ATTR_VERSION, version); chartConsumingMap.put(ATTR_VERSION, version);
chartConsumingMap.put(ATTR_USER_ID, userId);
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0");
chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew));
chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse));
ChartInfo chartInfo = new ChartInfo(chartId, templateId, book); ChartInfo chartInfo = new ChartInfo(chartId, templateId, book);
chartInfo.chartConsumingMap = chartConsumingMap; chartInfo.chartConsumingMap = chartConsumingMap;
chartProvider.initChartConfigInfo(chartInfo.chartConfigInfo);
return chartInfo; return chartInfo;
} }
@ -158,6 +184,7 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_DAY_COUNT, this.idleDayCount); writer.attr(ATTR_DAY_COUNT, this.idleDayCount);
} }
writer.attr(ATTR_TEST_TEMPLATE, this.testTemplate); writer.attr(ATTR_TEST_TEMPLATE, this.testTemplate);
writer.attr(ATTR_TEST_CHART, this.testChart);
writer.startTAG(XML_CHART_CONSUMING_MAP); writer.startTAG(XML_CHART_CONSUMING_MAP);
writer.attr(ATTR_USERNAME, chartConsumingMap.get(ATTR_USERNAME)); writer.attr(ATTR_USERNAME, chartConsumingMap.get(ATTR_USERNAME));
writer.attr(ATTR_UUID, chartConsumingMap.get(ATTR_UUID)); writer.attr(ATTR_UUID, chartConsumingMap.get(ATTR_UUID));
@ -170,7 +197,14 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_CHART_PROPERTY_END_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME)); writer.attr(ATTR_CHART_PROPERTY_END_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME));
writer.attr(ATTR_JAR_TIME, chartConsumingMap.get(ATTR_JAR_TIME)); writer.attr(ATTR_JAR_TIME, chartConsumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_VERSION, chartConsumingMap.get(ATTR_VERSION)); writer.attr(ATTR_VERSION, chartConsumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USER_ID, chartConsumingMap.get(ATTR_USER_ID));
writer.attr(ATTR_FIRST_CHART_TYPE, chartConsumingMap.get(ATTR_FIRST_CHART_TYPE));
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_REUSE, chartConsumingMap.get(ATTR_IS_REUSE));
writer.end(); writer.end();
chartConfigInfo.writeXML(writer);
writer.end(); writer.end();
} }
@ -182,6 +216,7 @@ public class ChartInfo extends AbstractPointInfo {
chartId = reader.getAttrAsString(ATTR_CHART_ID, StringUtils.EMPTY); chartId = reader.getAttrAsString(ATTR_CHART_ID, StringUtils.EMPTY);
templateId = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); templateId = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
testTemplate = reader.getAttrAsBoolean(ATTR_TEST_TEMPLATE, true); testTemplate = reader.getAttrAsBoolean(ATTR_TEST_TEMPLATE, true);
testChart = reader.getAttrAsBoolean(ATTR_TEST_CHART, false);
} else { } else {
String name = reader.getTagName(); String name = reader.getTagName();
if (XML_CHART_CONSUMING_MAP.equals(name)) { if (XML_CHART_CONSUMING_MAP.equals(name)) {
@ -198,6 +233,14 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_END_TIME, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_END_TIME, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0")); chartConsumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0"));
chartConsumingMap.put(ATTR_USER_ID, reader.getAttrAsString(ATTR_USER_ID, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, reader.getAttrAsString(ATTR_FIRST_CHART_TYPE, StringUtils.EMPTY));
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_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY));
}
if (ChartConfigInfo.XML_TAG.equals(name)) {
this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo());
} }
} }
} }
@ -212,9 +255,17 @@ public class ChartInfo extends AbstractPointInfo {
public Map<String, String> getSendInfo() { public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>(); Map<String, String> sendMap = new HashMap<>();
sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString()); sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString());
sendMap.put(CHART_FUNCTION_URL, getFunctionJson());
return sendMap; return sendMap;
} }
private String getFunctionJson() {
JSONObject jsonObject = JSONObject.create();
jsonObject.put("chartID", this.chartId);
chartConfigInfo.toJSONObject(jsonObject);
return jsonObject.toString();
}
public void updatePropertyTime() { public void updatePropertyTime() {
String propertyTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); String propertyTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
@ -224,13 +275,31 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, propertyTime); chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, propertyTime);
} }
public void updateChartType(String chartType) { public void updateChartType(ChartProvider chartProvider) {
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);
chartConsumingMap.put(ATTR_CHART_TYPE, chartType); chartConsumingMap.put(ATTR_CHART_TYPE, chartProvider.getID());
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, ""); chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, "");
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, "");
String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT);
count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count);
resetChartConfigInfo(chartProvider);
}
public void resetChartConfigInfo(ChartProvider chartProvider) {
chartConfigInfo.reset();
chartProvider.initChartConfigInfo(chartConfigInfo);
}
public void updateFirstType(String chartType) {
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType);
}
public void updateChartConfig(ConfigType configType, AbstractConfig config) {
chartConfigInfo.updateChartConfig(configType, config);
} }
@Override @Override
@ -245,6 +314,7 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(entry.getKey(), entry.getValue()); chartConsumingMap.put(entry.getKey(), entry.getValue());
} }
chartInfo.chartConsumingMap = chartConsumingMap; chartInfo.chartConsumingMap = chartConsumingMap;
chartInfo.chartConfigInfo = chartConfigInfo.clone();
return chartInfo; return chartInfo;
} }
} }

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

@ -2,20 +2,16 @@ package com.fr.design.mainframe.chart.info;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.attr.ChartProvider;
import com.fr.chartx.config.info.AbstractConfig;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.template.info.TemplateInfo; import com.fr.design.mainframe.template.info.TemplateInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; 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.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -53,72 +49,92 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
} }
public void collection(ChartProvider chartProvider, String createTime) { public void collection(ChartProvider chartProvider, String createTime) {
if (chartProvider instanceof VanChart) { collection(chartProvider, createTime, false);
VanChart vanChart = (VanChart) chartProvider;
collection(vanChart.getUuid(), vanChart.getID(), createTime);
}
} }
/** /**
* 新建图表保存状态 * 新建图表保存状态
*/ */
public void collection(String chartId, String chartType, String createTime) { public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) {
if (!shouldCollectInfo()) { String chartId = chartProvider.getChartUuid();
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
return; return;
} }
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse);
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime);
chartInfoCacheMap.put(chartId, chartInfo); chartInfoCacheMap.put(chartId, chartInfo);
} }
/**
* 图表编辑更新编辑时间
*/
public void updateChartPropertyTime(ChartProvider chartProvider) { public void updateChartPropertyTime(ChartProvider chartProvider) {
if (chartProvider instanceof VanChart) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
VanChart vanChart = (VanChart) chartProvider; return;
updateChartPropertyTime(vanChart.getUuid(), vanChart.getID());
} }
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider);
//更新编辑时间
chartInfo.updatePropertyTime();
//重置计数
chartInfo.resetIdleDayCount();
} }
/** /**
* 图表编辑更新编辑时间 * 图表编辑更新编辑时间
*/ */
public void updateChartPropertyTime(String chartId, String chartType) { public void updateChartConfig(ChartProvider chartProvider, ConfigType configType, AbstractConfig config) {
if (!shouldCollectInfo()) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return; return;
} }
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); ChartInfo chartInfo = getOrCreateChartInfo(chartProvider);
//更新编辑时间 //更新对应的配置
chartInfo.updatePropertyTime(); chartInfo.updateChartConfig(configType, config);
//重置计数 //重置计数
chartInfo.resetIdleDayCount(); chartInfo.resetIdleDayCount();
} }
public void updateChartTypeTime(ChartProvider chartProvider) { /**
if (chartProvider instanceof VanChart) { * 图表子类型更新
VanChart vanChart = (VanChart) chartProvider; */
updateChartTypeTime(vanChart.getUuid(), vanChart.getID()); public void updateChartMiniType(ChartProvider chartProvider) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return;
} }
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider);
//图表子类型更新
chartInfo.resetChartConfigInfo(chartProvider);
//重置计数
chartInfo.resetIdleDayCount();
} }
/** /**
* 图表类型变化更新类型和类型确认时间 * 图表类型变化更新类型和类型确认时间
*/ */
public void updateChartTypeTime(String chartId, String chartType) { public void updateChartTypeTime(ChartProvider chartProvider, String oldType) {
if (!shouldCollectInfo()) { if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return; return;
} }
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType);
//更新类型确认时间和类型 //更新类型确认时间和类型
chartInfo.updateChartType(chartType); chartInfo.updateChartType(chartProvider);
//重置计数 //重置计数
chartInfo.resetIdleDayCount(); chartInfo.resetIdleDayCount();
} }
private ChartInfo getOrCreateChartInfo(String chartId, String chartType) { private ChartInfo getOrCreateChartInfo(ChartProvider chartProvider) {
return getOrCreateChartInfo(chartProvider, null);
}
private ChartInfo getOrCreateChartInfo(ChartProvider chartProvider, String oldType) {
String chartId = chartProvider.getChartUuid();
//缓存中有从缓存中拿 //缓存中有从缓存中拿
if (chartInfoCacheMap.containsKey(chartId)) { if (chartInfoCacheMap.containsKey(chartId)) {
return chartInfoCacheMap.get(chartId); return chartInfoCacheMap.get(chartId);
@ -129,12 +145,26 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
chartInfoCacheMap.put(chartId, chartInfo); chartInfoCacheMap.put(chartId, chartInfo);
return chartInfo; return chartInfo;
} }
//都有的话创建一个并加入到缓存中 //都没有的话创建一个并加入到缓存中
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType); ChartInfo chartInfo = ChartInfo.newInstance(chartProvider);
if (StringUtils.isNotEmpty(oldType)) {
chartInfo.updateFirstType(oldType);
}
chartInfoCacheMap.put(chartId, chartInfo); chartInfoCacheMap.put(chartId, chartInfo);
return chartInfo; return chartInfo;
} }
public void checkTestChart(ChartProvider chartProvider) {
if (!shouldCollectInfo()) {
return;
}
ChartInfo chartInfo = chartInfoCacheMap.get(chartProvider.getChartUuid());
if (chartInfo != null) {
boolean testChart = chartProvider.isTestChart();
chartInfo.setTestChart(testChart);
}
}
/** /**
* 保存模板的时候将该模板中的图表埋点信息保存 * 保存模板的时候将该模板中的图表埋点信息保存
*/ */
@ -200,16 +230,8 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
* 获取缓存文件存放路径 * 获取缓存文件存放路径
*/ */
@Override @Override
protected File getInfoFile() { protected String getInfoFilePath() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); return XML_FILE_NAME;
try {
if (!file.exists()) {
file.createNewFile();
}
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return file;
} }
@Override @Override

7
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java → designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java

@ -21,6 +21,9 @@ import java.util.Date;
*/ */
public class ErrorInfo { public class ErrorInfo {
private static final String SUFFIX = ".json";
private static final String FOLDER_NAME = "errorInfo";
private String username; private String username;
private String uuid; private String uuid;
private String activekey; private String activekey;
@ -128,8 +131,8 @@ public class ErrorInfo {
public void saveFileToCache(JSONObject jo) { public void saveFileToCache(JSONObject jo) {
String content = jo.toString(); String content = jo.toString();
String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; String fileName = UUID.randomUUID() + SUFFIX;
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME, fileName));
FileOutputStream out = null; FileOutputStream out = null;
try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
StableUtils.makesureFileExist(file); StableUtils.makesureFileExist(file);

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

@ -45,7 +45,7 @@ public class DesignerLogHandler {
private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final int GAP_X = -150; private static final int GAP_X = -75;
private static final int INFO_GAP_Y = -60; private static final int INFO_GAP_Y = -60;
@ -53,6 +53,12 @@ public class DesignerLogHandler {
private static final int SERVER_GAP_Y = -20; private static final int SERVER_GAP_Y = -20;
private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":";
private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":";
private static final String NORMAL_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":";
public static DesignerLogHandler getInstance() { public static DesignerLogHandler getInstance() {
return HOLDER.singleton; return HOLDER.singleton;
@ -310,11 +316,11 @@ public class DesignerLogHandler {
private String appendLocaleMark(String str, int style) { private String appendLocaleMark(String str, int style) {
if (style == DesignerLogger.ERROR_INT) { if (style == DesignerLogger.ERROR_INT) {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n"; str = ERROR_MARK + str + "\n";
} else if (style == DesignerLogger.WARN_INT) { } else if (style == DesignerLogger.WARN_INT) {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":" + str + "\n"; str = WARN_MARK + str + "\n";
} else { } else {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":" + str + "\n"; str = NORMAL_MARK + str + "\n";
} }
return str; return str;
} }

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

@ -6,6 +6,7 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
public class LogDetailPane extends JPanel{ public class LogDetailPane extends JPanel{
@ -20,7 +21,7 @@ public class LogDetailPane extends JPanel{
fr.setSize(600, 400); fr.setSize(600, 400);
GUICoreUtils.centerWindow(fr); GUICoreUtils.centerWindow(fr);
fr.setResizable(false); fr.setResizable(false);
fr.setTitle("日志"); fr.setTitle(Toolkit.i18nText("Fine-Design_Basic_Log"));
fr.setIconImage(BaseUtils.readImageWithCache("com/fr/design/images/buttonicon/history.png")); fr.setIconImage(BaseUtils.readImageWithCache("com/fr/design/images/buttonicon/history.png"));
fr.getContentPane().setLayout(new BorderLayout()); fr.getContentPane().setLayout(new BorderLayout());
fr.getContentPane().add(this, BorderLayout.CENTER); fr.getContentPane().add(this, BorderLayout.CENTER);

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

@ -2,26 +2,39 @@ package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.ui.util.UIUtil;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.fr.design.i18n.Toolkit.i18nText;
public class LogHandlerBar extends JPanel implements ItemSelectable { public class LogHandlerBar extends JPanel implements ItemSelectable {
// 可以作为常量 提前初始化 不用每次都去实时频繁的读取
private static final String NORMAL_MARK = i18nText("Fine-Design_Basic_NNormal");
private static final String ALERT_MARK = i18nText("Fine-Design_Basic_Alert");
private static final String SERIOUSLY_MARK = i18nText("Fine-Design_Basic_Seriously");
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private ItemListener listeners; private ItemListener listeners;
private UIButton clear; private UIButton clear;
private UIButton selectedall; private UIButton selectedall;
private UIButton set; private UIButton set;
private UILabel normalLabel;
private UILabel alertLabel;
private UILabel seriouslyLabel;
private String text; private String text;
private int INFONUM = 0; private int INFONUM = 0;
private int ERRORNUM = 0; private int ERRORNUM = 0;
private int SERVERNUM = 0; private int SERVERNUM = 0;
private static final int FLOW_LAYOUT_HGAP = 10;
private static final int FLOW_LAYOUT_VGAP = 5;
private boolean isWithSerious; private boolean isWithSerious;
@ -30,33 +43,57 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
} }
public LogHandlerBar(String text) { public LogHandlerBar(String text) {
this.setLayout(new CaptionLayout()); this.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOW_LAYOUT_HGAP, FLOW_LAYOUT_VGAP));
this.setUI(new LogHandlerBarUI()); this.setUI(new LogHandlerBarUI());
this.text = text; this.text = text;
clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png")); clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png"));
clear.setMargin(null); clear.setMargin(null);
clear.setOpaque(false); clear.setOpaque(false);
clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
clear.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All")); clear.setToolTipText(i18nText("Fine-Design_Basic_Clear_All"));
selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png")); selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png"));
selectedall.setMargin(null); selectedall.setMargin(null);
selectedall.setOpaque(false); selectedall.setOpaque(false);
selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
selectedall.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All")); selectedall.setToolTipText(i18nText("Fine-Design_Basic_Select_All"));
set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png")); set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png"));
set.setMargin(null); set.setMargin(null);
set.setOpaque(false); set.setOpaque(false);
set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
set.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")); set.setToolTipText(i18nText("Fine-Design_Report_Set"));
normalLabel = new UILabel(i18nText("Fine-Design_Basic_NNormal") + "(0)");
alertLabel = new UILabel(i18nText("Fine-Design_Basic_Alert") + "(0)");
seriouslyLabel = new UILabel(i18nText("Fine-Design_Basic_Seriously") + "(0)");
this.add(normalLabel);
this.add(alertLabel);
this.add(seriouslyLabel);
this.add(clear); this.add(clear);
this.add(selectedall); this.add(selectedall);
this.add(set); this.add(set);
} }
/**
* 更新日志数量统计标签
*/
private void changeLabel() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
// 这块逻辑执行地很频繁
// 容易造成 AWT 与 FinePluginController 发生死锁
// in18Text每次读取 资源的时候 都会走下插件引擎逻辑去读取下插件的资源
// 应该避免每次都去读取 可以作为常量提前初始化好 避免与FinePluginController的竞争
normalLabel.setText(NORMAL_MARK + '(' + getInfo() + ')');
alertLabel.setText(ALERT_MARK + '(' + getError() + ')');
seriouslyLabel.setText(SERIOUSLY_MARK + '(' + getServer() + ')');
}
});
}
public void clearMessage() { public void clearMessage() {
INFONUM = ERRORNUM = SERVERNUM = 0; INFONUM = ERRORNUM = SERVERNUM = 0;
repaint(); changeLabel();
} }
public boolean IsWithSerious() { public boolean IsWithSerious() {
@ -69,27 +106,17 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void infoAdd() { public void infoAdd() {
INFONUM++; INFONUM++;
repaint(); changeLabel();
} }
public void errorAdd() { public void errorAdd() {
ERRORNUM++; ERRORNUM++;
timerPaint(); changeLabel();
} }
public void serverAdd() { public void serverAdd() {
SERVERNUM++; SERVERNUM++;
timerPaint(); changeLabel();
}
private AtomicBoolean painting = new AtomicBoolean(false);
public void timerPaint() {
if(!painting.get()) {
painting.set(true);
repaint();
painting.set(false);
}
} }
public int getInfo() { public int getInfo() {
@ -141,44 +168,4 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void addSetListener(ActionListener l) { public void addSetListener(ActionListener l) {
set.addActionListener(l); set.addActionListener(l);
} }
private class CaptionLayout implements LayoutManager {
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return new Dimension(120, 24);
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return new Dimension(0, 0);
}
@Override
public void layoutContainer(Container target) {
Insets insets = target.getInsets();
int top = insets.top;
int right = target.getWidth() - insets.right;
clear.setBounds(right - CLEAR_OFFSET, top + TOP_OFFSET, clear.getPreferredSize().width, clear.getPreferredSize().height);
selectedall.setBounds(right - SELECT_OFFSET, top + TOP_OFFSET, selectedall.getPreferredSize().width, selectedall.getPreferredSize().height);
set.setBounds(right - SET_OFFSET, top + TOP_OFFSET, set.getPreferredSize().width, set.getPreferredSize().height);
}
private static final int CLEAR_OFFSET = 130;
private static final int TOP_OFFSET = 4;
private static final int SELECT_OFFSET = 100;
private static final int SET_OFFSET = 70;
}
} }

9
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java

@ -1,5 +1,7 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.FontMetrics; import java.awt.FontMetrics;
@ -11,9 +13,6 @@ import java.awt.event.FocusListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener { public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener {
@ -99,10 +98,6 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus
if (button.getText() != null) { if (button.getText() != null) {
g.drawString(button.getText(), textLeadingGap, y); g.drawString(button.getText(), textLeadingGap, y);
} }
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_NNormal") + '(' + button.getInfo() + ')', button.getWidth() - 310, y);
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + '(' + button.getError() + ')', button.getWidth() - 250, y);
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + '(' + button.getServer() + ')', button.getWidth() - 190, y);
} }
/** /**

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

@ -12,6 +12,9 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
public class LogMessageBar extends JPanel { public class LogMessageBar extends JPanel {
private static final String LOG_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log");
private UILabel messageLabel; private UILabel messageLabel;
private int width = 600; private int width = 600;
private static volatile LogMessageBar THIS; private static volatile LogMessageBar THIS;
@ -56,7 +59,7 @@ public class LogMessageBar extends JPanel {
if (message == null) { if (message == null) {
return; return;
} }
messageLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log") + " | " + message); messageLabel.setText(LOG_MARK + " | " + message);
repaint(); repaint();
} }

3
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java → designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java

@ -1,8 +1,8 @@
package com.fr.design.mainframe.messagecollect; package com.fr.design.mainframe.messagecollect;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.errorinfo.ErrorInfo; import com.fr.design.mainframe.errorinfo.ErrorInfo;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** /**
@ -30,6 +30,7 @@ public class StartErrorMessageCollector {
} }
public void record(String id, String msg, String detail) { public void record(String id, String msg, String detail) {
FineLoggerFactory.getLogger().error(id + ": " + msg + ", detail: " + detail);
ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey); ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey);
errorInfo.setLogid(id); errorInfo.setLogid(id);
errorInfo.setLog(msg); errorInfo.setLog(msg);

0
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java → designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java

6
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java

@ -30,11 +30,15 @@ public class MobileBookMarkStyleDefinePane extends BasicBeanPane<MobileBookMarkS
private void initComponent() { private void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel settingPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel settingPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
if (!ComparatorUtils.equals(displayName, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"))) { if (!ComparatorUtils.equals(displayName, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"))) {
JPanel hintLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
hintLabelPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Hint")); UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Hint"));
hintLabel.setForeground(Color.GRAY); hintLabel.setForeground(Color.GRAY);
settingPane.add(hintLabel, BorderLayout.NORTH); hintLabelPane.add(hintLabel);
settingPane.add(hintLabelPane, BorderLayout.NORTH);
} }
settingPane.add(this.customDefinePane, BorderLayout.CENTER); settingPane.add(this.customDefinePane, BorderLayout.CENTER);
this.add(settingPane, BorderLayout.CENTER); this.add(settingPane, BorderLayout.CENTER);

16
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java

@ -7,6 +7,8 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.ui.mobile.MobileBookMarkStyle; import com.fr.form.ui.mobile.MobileBookMarkStyle;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -23,6 +25,11 @@ import java.util.Set;
* Created by hades on 2019/12/23 * Created by hades on 2019/12/23
*/ */
public class MobileBookMarkStylePane extends BasicBeanPane<MobileBookMarkStyle> { public class MobileBookMarkStylePane extends BasicBeanPane<MobileBookMarkStyle> {
public static final int LEFT_PANEL_WIDTH = 140;
public static final int LEFT_PANEL_HEIGHT = 565;
public static final int RIGHT_PANEL_WIDTH = 510;
public static final int RIGHT_PANEL_HEIGHT = 565;
public static ListCellRenderer renderer = new DefaultListCellRenderer() { public static ListCellRenderer renderer = new DefaultListCellRenderer() {
@Override @Override
@ -48,6 +55,7 @@ public class MobileBookMarkStylePane extends BasicBeanPane<MobileBookMarkStyle>
private void initComponent() { private void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.listModel = new DefaultListModel<>(); this.listModel = new DefaultListModel<>();
this.card = new CardLayout(); this.card = new CardLayout();
this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane(); this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane();
@ -79,14 +87,16 @@ public class MobileBookMarkStylePane extends BasicBeanPane<MobileBookMarkStyle>
} }
}); });
JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
leftPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
leftPanel.add(bookMarkList, BorderLayout.CENTER); leftPanel.add(bookMarkList, BorderLayout.CENTER);
leftPanel.setPreferredSize(new Dimension(100, 500)); leftPanel.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, LEFT_PANEL_HEIGHT));
this.add(leftPanel, BorderLayout.WEST); this.add(leftPanel, BorderLayout.WEST);
} }
private void initRightPanel() { private void initRightPanel() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPane.setPreferredSize(new Dimension(500, 500)); centerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
centerPane.setPreferredSize(new Dimension(RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT));
centerPane.add(rightPane, BorderLayout.CENTER); centerPane.add(rightPane, BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
} }
@ -94,10 +104,12 @@ public class MobileBookMarkStylePane extends BasicBeanPane<MobileBookMarkStyle>
private List<MobileBookMarkStyleProvider> getMobileBookMarkStyleProvider() { private List<MobileBookMarkStyleProvider> getMobileBookMarkStyleProvider() {
DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider(); DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider();
SidebarMobileBookMarkStyleProvider sidebarMobileBookMarkStyleProvider = new SidebarMobileBookMarkStyleProvider();
Set<MobileBookMarkStyleProvider> mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray( Set<MobileBookMarkStyleProvider> mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray(
MobileBookMarkStyleProvider.XML_TAG); MobileBookMarkStyleProvider.XML_TAG);
List<MobileBookMarkStyleProvider> list = new ArrayList<>(); List<MobileBookMarkStyleProvider> list = new ArrayList<>();
list.add(defaultMobileBookMarkStyleProvider); list.add(defaultMobileBookMarkStyleProvider);
list.add(sidebarMobileBookMarkStyleProvider);
list.addAll(mobileBookMarkStyleProviders); list.addAll(mobileBookMarkStyleProviders);
return Collections.unmodifiableList(list); return Collections.unmodifiableList(list);
} }

50
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java

@ -6,13 +6,12 @@ import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.UITitleSplitLine; import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.mobile.MobileCollapsedStyle; import com.fr.form.ui.mobile.MobileCollapsedStyle;
import com.fr.form.ui.mobile.MobileFormCollapsedStyle; import com.fr.form.ui.mobile.MobileFormCollapsedStyle;
import javax.swing.JPanel; import javax.swing.*;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Dimension;
/** /**
* @author hades * @author hades
@ -21,34 +20,45 @@ import java.awt.Dimension;
*/ */
public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane {
private static final Dimension DEFAULT_SPINNER_SIZE = new Dimension(60, 24);
private UISpinner rowSpinner; private UISpinner rowSpinner;
public MobileCollapsedStyleExpandPane() { public MobileCollapsedStyleExpandPane() {
} }
@Override @Override
protected JPanel createLinePane() { protected void createConfigPanes(JPanel settingPane) {
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"), 520); JPanel lineNumberConfigPane = this.createLineNumberConfigPane();
splitLine.setPreferredSize(new Dimension(520, 20)); settingPane.add(lineNumberConfigPane);
super.createConfigPanes(settingPane);
}
protected JPanel createLineNumberConfigPane() {
JPanel configPane = super.createTitleConfigPane(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"));
UILabel collapseLocationLabel = createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button"));
this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) { this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) {
@Override @Override
protected UINumberField initNumberField(){ protected UINumberField initNumberField(){
return new UIIntNumberField(); return new UIIntNumberField();
} }
}; };
rowSpinner.setPreferredSize(DEFAULT_SPINNER_SIZE); this.rowSpinner.setPreferredSize(new Dimension(62, COMPONENT_HEIGHT));
JPanel panel = new JPanel(); JPanel defaultCollapsedStatePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); defaultCollapsedStatePanel.add(createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From") + " "));
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From"))); defaultCollapsedStatePanel.add(rowSpinner);
panel.add(rowSpinner); defaultCollapsedStatePanel.add(createLabel(" " + Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold")));
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold")));
JPanel linePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); double[] rowSize = {COMPONENT_HEIGHT};
linePane.add(splitLine, BorderLayout.NORTH); double[] columnSize = {LABEL_WIDTH, COMPONENT_WIDTH};
linePane.add(panel, BorderLayout.CENTER); double[] verticalGaps = {0};
return linePane; JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{
{collapseLocationLabel, defaultCollapsedStatePanel},
}, rowSize, columnSize, 5, verticalGaps);
navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0));
configPane.add(navButtonSettingsPanel);
return configPane;
} }
@Override @Override

153
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java

@ -1,8 +1,6 @@
package com.fr.design.mainframe.mobile.ui; package com.fr.design.mainframe.mobile.ui;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ibutton.ModeButtonGroup; import com.fr.design.gui.ibutton.ModeButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
@ -10,9 +8,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.widget.UITitleSplitLine; import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
@ -21,13 +17,7 @@ import com.fr.form.ui.mobile.MobileChartCollapsedStyle;
import com.fr.form.ui.mobile.MobileCollapsedStyle; import com.fr.form.ui.mobile.MobileCollapsedStyle;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.TitledBorder; import java.awt.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
/** /**
* @author hades * @author hades
@ -36,6 +26,13 @@ import java.awt.FlowLayout;
*/ */
public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle> { public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle> {
public final static Color THEME_COLOR = Color.decode("#2F8EF1");
public final static Font TEXT_FONT = new Font("Default", Font.PLAIN, 12);
public final static Color TEXT_FONT_COLOR = Color.decode("#333334");
public final static int LABEL_WIDTH = 96;
public final static int COMPONENT_HEIGHT = 20;
public final static int COMPONENT_WIDTH = 160;
private UICheckBox showButtonCheck; private UICheckBox showButtonCheck;
private NewColorSelectBox buttonColorBox; private NewColorSelectBox buttonColorBox;
private UITextField foldedTextFiled; private UITextField foldedTextFiled;
@ -44,74 +41,94 @@ public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle
public MobileCollapsedStylePane() { public MobileCollapsedStylePane() {
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10); this.setBorder(BorderFactory.createEmptyBorder( 10, 5, 0, 5));
layout.setAlignLeft(true);
this.setBorder(titledBorder); JPanel settingPane = this.createSettingPane();
this.setLayout(layout); this.createConfigPanes(settingPane);
this.add(createLinePane());
this.add(createSettingPane()); this.add(settingPane);
} }
private JPanel createSettingPane() { private JPanel createSettingPane() {
JPanel settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0); JPanel settingPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"), 520); settingPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"), THEME_COLOR));
splitLine.setPreferredSize(new Dimension(520, 20)); return settingPane;
UILabel showButtonLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button")); }
showButtonCheck = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right"));
showButtonCheck.setPreferredSize(new Dimension(140, 24)); protected UILabel createLabel(String text) {
UILabel buttonColorLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color")); UILabel label = new UILabel(text, SwingConstants.RIGHT);
buttonColorBox = new NewColorSelectBox(137); label.setForeground(TEXT_FONT_COLOR);
UILabel foldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint")); label.setFont(TEXT_FONT);
return label;
}
protected void createConfigPanes(JPanel settingPane) {
JPanel collapsedButtonConfigPane = this.createCollapsedButtonConfigPane();
settingPane.add(collapsedButtonConfigPane);
}
protected JPanel createTitleConfigPane(String title) {
JPanel configPane = new JPanel();
configPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
configPane.setLayout(new BoxLayout(configPane, BoxLayout.Y_AXIS));
Dimension titleLineDim = new Dimension(610, 20);
UITitleSplitLine splitLine = new UITitleSplitLine(title, titleLineDim.width);
splitLine.setPreferredSize(titleLineDim);
configPane.add(splitLine);
return configPane;
}
private JPanel createCollapsedButtonConfigPane() {
JPanel configPane = this.createTitleConfigPane(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"));
UILabel showButtonLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button"));
showButtonCheck = new UICheckBox(Toolkit.i18nText(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right")));
showButtonCheck.setForeground(TEXT_FONT_COLOR);
showButtonCheck.setFont(TEXT_FONT);
UILabel buttonColorLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color"));
buttonColorBox = new NewColorSelectBox(COMPONENT_WIDTH);
UILabel foldedLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint"));
foldedTextFiled = new UITextField(); foldedTextFiled = new UITextField();
UILabel unfoldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint"));
UILabel unfoldedLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint"));
unfoldedTextFiled = new UITextField(); unfoldedTextFiled = new UITextField();
UILabel defaultStateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State"));
buttonGroup = new ModeButtonGroup<>(); UILabel defaultCollapsedStateLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State"));
JPanel defaultCollapsedStatePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold")); UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold"));
foldedButton.setSelected(true); foldedButton.setSelected(true);
foldedButton.setPreferredSize(new Dimension(COMPONENT_WIDTH / 2, COMPONENT_HEIGHT));
foldedButton.setForeground(TEXT_FONT_COLOR);
foldedButton.setFont(TEXT_FONT);
UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold")); UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold"));
unfoldedButton.setPreferredSize(new Dimension(COMPONENT_WIDTH / 2, COMPONENT_HEIGHT));
unfoldedButton.setForeground(TEXT_FONT_COLOR);
unfoldedButton.setFont(TEXT_FONT);
defaultCollapsedStatePanel.add(foldedButton);
defaultCollapsedStatePanel.add(unfoldedButton);
buttonGroup = new ModeButtonGroup<>();
buttonGroup.put(CollapseState.FOLDED, foldedButton); buttonGroup.put(CollapseState.FOLDED, foldedButton);
buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton); buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton);
JPanel flowLeftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
flowLeftPane.add(foldedButton);
flowLeftPane.add(unfoldedButton);
Component[][] northComponents = new Component[][] {
new Component[] {showButtonLabel, showButtonCheck}
};
Component[][] southComponents = new Component[][] {
new Component[] {defaultStateLabel, flowLeftPane}
};
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p};
double[] colSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
Component[][] centerComponents = new Component[][] {
new Component[] {buttonColorLabel, buttonColorBox},
new Component[] {foldedLabel, foldedTextFiled},
new Component[] {unfoldedLabel, unfoldedTextFiled},
};
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(northComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1);
JPanel southPane = TableLayoutHelper.createGapTableLayoutPane(southComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
final JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, colSize, rowCount, LayoutConstants.HGAP_LARGE, LayoutConstants.VGAP_SMALL);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(northPane, BorderLayout.NORTH);
panel.add(centerPane, BorderLayout.CENTER);
panel.add(southPane, BorderLayout.SOUTH);
settingPane.add(splitLine);
settingPane.add(panel);
showButtonCheck.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
centerPane.setVisible(showButtonCheck.isSelected());
}
});
return settingPane;
}
protected JPanel createLinePane() { double[] rowSize = {COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT};
return FRGUIPaneFactory.createBorderLayout_S_Pane(); double[] columnSize = {LABEL_WIDTH, COMPONENT_WIDTH};
double[] verticalGaps = {10, 10, 10, 10, 10};
JPanel contentPane = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{
{showButtonLabel, showButtonCheck},
{buttonColorLabel, buttonColorBox},
{foldedLabel, foldedTextFiled},
{unfoldedLabel, unfoldedTextFiled},
{defaultCollapsedStateLabel, defaultCollapsedStatePanel}
}, rowSize, columnSize, 5, verticalGaps);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0));
configPane.add(contentPane);
return configPane;
} }
@Override @Override

5
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java

@ -9,8 +9,8 @@ import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.mobile.MobileCollapsedStyle; import com.fr.form.ui.mobile.MobileCollapsedStyle;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import javax.swing.SwingUtilities; import javax.swing.*;
import java.awt.Dimension; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -33,6 +33,7 @@ public class MobileComboBoxDialogEditor extends BasicPane {
private ActionListener listener; private ActionListener listener;
public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) { public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) {
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.stylePane = stylePane; this.stylePane = stylePane;
this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM}); this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM});
this.comboBox.setPreferredSize(COMBOX_DIMENSION); this.comboBox.setPreferredSize(COMBOX_DIMENSION);

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

@ -2,29 +2,54 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox;
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.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle; import com.fr.form.ui.mobile.MobileStyle;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
private static final int NORMAL_COMBO_WIDTH = 152;
private Widget widget; private Widget widget;
private MobileStyleCustomDefinePane customBeanPane; private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz; private Class<? extends MobileStyle> mobileStyleClazz;
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 LineComboBox borderType;
private NewColorSelectBox borderColor;
private UISpinner borderRadius;
private NewColorSelectBox iconColor;
private MobileStyleFontConfigPane fontConfigPane;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) { Class<? extends MobileStyle> mobileStyleClazz) {
@ -40,6 +65,17 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
if(ob.getBackground() != null) { if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor()); colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
} }
borderType.setSelectedLineStyle(ob.getBorderType());
if (ob.getBorderColor() != null) {
borderColor.setSelectObject(ob.getBorderColor());
}
borderRadius.setValue(ob.getBorderRadius());
if (ob.getIconColor() != null) {
iconColor.setSelectObject(ob.getIconColor());
}
if (ob.getFont() != null) {
fontConfigPane.populateBean(ob.getFont());
}
} }
@Override @Override
@ -48,6 +84,11 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject())); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject());
mobileStyle.setBorderRadius(borderRadius.getValue());
mobileStyle.setIconColor(iconColor.getSelectObject());
mobileStyle.setFont(fontConfigPane.updateBean());
return mobileStyle; return mobileStyle;
} }
@ -64,7 +105,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private void createGeneralPane() { private void createGeneralPane() {
createPreviewPane(); createPreviewPane();
createBackgroundPane(); createCommonPane();
} }
private void createPreviewPane() { private void createPreviewPane() {
@ -79,29 +120,45 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
} }
} }
private void createBackgroundPane() { private void createCommonPane() {
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"));
commomPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
commomPane.setBorder(titledBorder);
this.add(commomPane, BorderLayout.NORTH);
JPanel backgroundPane = new JPanel(); createBackgroundPane();
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); createBorderPane();
backgroundPane.setPreferredSize(new Dimension(500, 65)); createIconSettingPane();
createFontPane();
}
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute")); private void createBackgroundPane() {
backgroundPane.setBorder(titledBorder); colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH);
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox);
colorSelectLabel.setPreferredSize(new Dimension(65, 20)); commomPane.add(backgroundPane);
}
colorSelectBox = new ColorSelectBox(152); private void createBorderPane() {
colorSelectBox.addSelectChangeListener(new ChangeListener() { borderType = new LineComboBox(BORDER_LINE_STYLE_ARRAY);
@Override borderType.setSelectedLineStyle(Constants.LINE_THIN);
public void stateChanged(ChangeEvent e) { borderType.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
} }
});
backgroundPane.add(colorSelectLabel); private void createIconSettingPane() {
backgroundPane.add(colorSelectBox); iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
}
this.add(backgroundPane, BorderLayout.NORTH); private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane();
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
} }
private void createCustomPane() { private void createCustomPane() {
@ -109,6 +166,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set")); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"));
configPane.setBorder(titledBorder); configPane.setBorder(titledBorder);
JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
configPane.add(this.customBeanPane, BorderLayout.CENTER); configPane.add(this.customBeanPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER); this.add(configPane, BorderLayout.CENTER);
@ -119,4 +177,14 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12)); titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12));
return titledBorder; return titledBorder;
} }
private UILabel createConfigLabel(String title) {
UILabel label = new UILabel(title + ":", UILabel.RIGHT);
label.setPreferredSize(new Dimension(75, 20));
return label;
}
private JPanel createLeftRightComponentsPane(Component... components) {
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
}
} }

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

@ -0,0 +1,123 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.Vector;
public class MobileStyleFontConfigPane extends JPanel {
public static final int FONT_NONE = 0;
private static final int MAX_FONT_SIZE = 18;
private static final int MIN_FONT_SIZE = 12;
private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>();
FONT_SIZES.add(FONT_NONE);
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
return FONT_SIZES;
}
private UIComboBox fontSizeComboBox;
private UIToggleButton underline;
private UIToggleButton italic;
private UIToggleButton bold;
public MobileStyleFontConfigPane() {
this.initComponent();
}
private void initComponent() {
fontSizeComboBox = new UIComboBox();
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes()));
fontSizeComboBox.setSelectedItem(0);
fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setRenderer(new LineCellRenderer());
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.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"));
this.setButtonsTips();
this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{
fontSizeComboBox, underline, italic, bold
};
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE));
this.setLayout(new BorderLayout(0,0));
this.add(buttonPane, BorderLayout.CENTER);
}
private void setButtonsTips() {
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold"));
}
private void setButtonsSize(Dimension size) {
underline.setPreferredSize(size);
italic.setPreferredSize(size);
bold.setPreferredSize(size);
}
public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE);
}
public FRFont updateBean() {
int style = Font.PLAIN;
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN;
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN;
return FRFont.getInstance(
FRFont.DEFAULT_FONTNAME,
style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
Color.BLACK,
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE
);
}
private class LineCellRenderer extends UIComboBoxRenderer {
public LineCellRenderer() {
super();
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
int currentValue = ((Integer) value).intValue();
if (currentValue == MobileStyleFontConfigPane.FONT_NONE) {
renderer.setText(StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"));
}
return renderer;
}
}
}

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

@ -63,6 +63,7 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
protected void init() { protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
previewPane = createPreviewPane(); previewPane = createPreviewPane();
if (previewPane != null) {
previewPane.setPreferredSize(new Dimension(500, 60)); previewPane.setPreferredSize(new Dimension(500, 60));
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null); TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null);
@ -71,6 +72,7 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
northPane.setPreferredSize(new Dimension(500, 83)); northPane.setPreferredSize(new Dimension(500, 83));
northPane.add(previewPane, BorderLayout.CENTER); northPane.add(previewPane, BorderLayout.CENTER);
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
}
createConfigPane(); createConfigPane();
} }
@ -111,18 +113,7 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
outPanel.add(jPanel); outPanel.add(jPanel);
scrollPanel.add(outPanel, BorderLayout.NORTH); scrollPanel.add(outPanel, BorderLayout.NORTH);
UITitleSplitLine backgroundSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 520); createBuiltinConfPane(centerPane);
backgroundSplit.setPreferredSize(new Dimension(520, 20));
centerPane.add(backgroundSplit);
centerPane.add(createBackgroundConfPane());
UITitleSplitLine fontSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Char"), 520);
fontSplit.setPreferredSize(new Dimension(520, 20));
centerPane.add(fontSplit);
centerPane.add(createFontConfPane());
createExtraConfPane(centerPane); createExtraConfPane(centerPane);
scrollPanel.add(centerPane, BorderLayout.CENTER); scrollPanel.add(centerPane, BorderLayout.CENTER);
@ -169,6 +160,19 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
return jPanel3; return jPanel3;
} }
protected void createBuiltinConfPane(JPanel centerPane) {
UITitleSplitLine backgroundSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 520);
backgroundSplit.setPreferredSize(new Dimension(520, 20));
centerPane.add(backgroundSplit);
centerPane.add(createBackgroundConfPane());
UITitleSplitLine fontSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Char"), 520);
fontSplit.setPreferredSize(new Dimension(520, 20));
centerPane.add(fontSplit);
centerPane.add(createFontConfPane());
}
protected void createExtraConfPane(JPanel centerPane) { protected void createExtraConfPane(JPanel centerPane) {
@ -184,8 +188,12 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
populateSubStyle(ob); populateSubStyle(ob);
custom.setSelectedItem(!ob.isCustom() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default") : custom.setSelectedItem(!ob.isCustom() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default") :
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom")); com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom"));
if (initialColorBox != null) {
initialColorBox.setSelectObject(ob.getInitialColor()); initialColorBox.setSelectObject(ob.getInitialColor());
}
if (fontConfPane != null) {
fontConfPane.populate(ob.getTabFontConfig().getFont()); fontConfPane.populate(ob.getTabFontConfig().getFont());
}
updatePreviewPane(); updatePreviewPane();
} }
@ -207,21 +215,27 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
} }
MobileTemplateStyle ob = updateSubStyle(); MobileTemplateStyle ob = updateSubStyle();
ob.setCustom(custom.getSelectedIndex() == 1); ob.setCustom(custom.getSelectedIndex() == 1);
if (initialColorBox != null) {
ob.setInitialColor(initialColorBox.getSelectObject()); ob.setInitialColor(initialColorBox.getSelectObject());
}
if (fontConfPane != null) {
TabFontConfig config = new TabFontConfig(); TabFontConfig config = new TabFontConfig();
config.setSelectColor(ob.getTabFontConfig().getSelectColor()); config.setSelectColor(ob.getTabFontConfig().getSelectColor());
config.setFont(fontConfPane.update()); config.setFont(fontConfPane.update());
ob.setTabFontConfig(config); ob.setTabFontConfig(config);
}
return ob; return ob;
} }
protected abstract MobileTemplateStyle getDefaultTemplateStyle(); protected abstract MobileTemplateStyle getDefaultTemplateStyle();
public void updatePreviewPane() { public void updatePreviewPane() {
if (previewPane != null) {
previewPane.populateConfig(updateConfig()); previewPane.populateConfig(updateConfig());
previewPane.setBackground(previewPane.getInitialColor()); previewPane.setBackground(previewPane.getInitialColor());
previewPane.repaint(); previewPane.repaint();
} }
}
public abstract void populateSubStyle(MobileTemplateStyle ob); public abstract void populateSubStyle(MobileTemplateStyle ob);

396
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java

@ -0,0 +1,396 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
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.ispinner.UnsignedIntUISpinner;
import com.fr.design.gui.style.FRFontPane;
import com.fr.design.gui.style.NumberDragBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.mobile.MobileBookMarkStyle;
import com.fr.form.ui.mobile.impl.SidebarMobileBookMarkStyle;
import com.fr.stable.CoreConstants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
/**
* @author Starryi
* @version 10.0
* Created by Starryi on 2020/02/28
*/
public class SidebarMobileBookMarkStyleCustomDefinePane extends BasicBeanPane<MobileBookMarkStyle> {
private static final long serialVersionUID = 1L;
private static final int COLUMN_HEIGHT = 20;
private static final int COLUMN_WIDTH = 160;
private UnsignedIntUISpinner buttonWidthSpinner;
private UnsignedIntUISpinner buttonHeightSpinner;
private UnsignedIntUISpinner buttonGapSpinner;
private UnsignedIntUISpinner buttonBorderRadiusSpinner;
private ColorSelectBox normalBackgroundColorBox;
private NumberDragBar normalOpacityDragBar;
private UnsignedIntUISpinner normalOpacitySpinner;
private LineComboBox normalBorderWidthComBox;
private ColorSelectBox normalBorderColorBox;
private UIComboBox normalFontNameComboBox;
private UIComboBox normalFontSizeComboBox;
private UIColorButton normalFontColorButton;
private UIToggleButton normalFontItalicButton;
private UIToggleButton normalFontBoldButton;
private ColorSelectBox selectedBackgroundColorBox;
private NumberDragBar selectedOpacityDragBar;
private UnsignedIntUISpinner selectedOpacitySpinner;
private LineComboBox selectedBorderWidthComBox;
private ColorSelectBox selectedBorderColorBox;
private UIComboBox selectedFontNameComboBox;
private UIComboBox selectedFontSizeComboBox;
private UIColorButton selectedFontColorButton;
private UIToggleButton selectedFontItalicButton;
private UIToggleButton selectedFontBoldButton;
private SidebarMobileBookMarkStyle DEFAULT_STYLE = new SidebarMobileBookMarkStyle();
public SidebarMobileBookMarkStyleCustomDefinePane() {
this.initComponent();
}
private void initComponent() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
final JPanel contentPanel = FRGUIPaneFactory.createYBoxEmptyBorderPane();
contentPanel.add(this.createNavButtonStylePanel());
contentPanel.add(this.createNormalStateStylePanel());
contentPanel.add(this.createSelectedStateStylePanel());
JPanel scrollPanel = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return contentPanel;
}
};
scrollPanel.setPreferredSize(new Dimension(-2, -2));
this.add(scrollPanel, BorderLayout.CENTER);
}
private JPanel createNavButtonStylePanel() {
buttonWidthSpinner = new UnsignedIntUISpinner(20, 150, 1, DEFAULT_STYLE.getWidth());
buttonHeightSpinner = new UnsignedIntUISpinner(20, 100, 1, DEFAULT_STYLE.getHeight());
buttonGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getGap());
buttonBorderRadiusSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getBorderRadius());
UILabel sizeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Size") + ":",
SwingConstants.RIGHT);
JPanel sizePane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 4, 0);
sizePane.add(buttonWidthSpinner);
sizePane.add(buttonHeightSpinner);
JPanel sizeTipsPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 4, 0);
sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Width"),
SwingConstants.CENTER));
sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Height"),
SwingConstants.CENTER));
UILabel gapLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Gap") + ":",
SwingConstants.RIGHT);
UILabel borderRadiusLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Border_Radius") + ":",
SwingConstants.RIGHT);
double p = TableLayout.PREFERRED;
double[] rowSize = {COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT};
double[] columnSize = {p, COLUMN_WIDTH};
double[] verticalGaps = {0, 10, 10};
JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{
{sizeLabel, sizePane},
{null, sizeTipsPane},
{gapLabel, buttonGapSpinner},
{borderRadiusLabel, buttonBorderRadiusSpinner},
}, rowSize, columnSize, 5, verticalGaps);
navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
containerPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Style"),
Color.decode("#2F8EF1")));
containerPane.add(navButtonSettingsPanel);
return containerPane;
}
private JPanel createNormalStateStylePanel() {
double p = TableLayout.PREFERRED;
normalBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH);
normalBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getBackgroundColor());
normalOpacityDragBar = new NumberDragBar(0, 100);
normalOpacityDragBar.setValue(DEFAULT_STYLE.getOpacity());
normalOpacityDragBar.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
normalOpacitySpinner.setValue(normalOpacityDragBar.getValue());
}
});
normalOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getOpacity());
normalOpacitySpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
normalOpacityDragBar.setValue((int) normalOpacitySpinner.getValue());
}
});
normalBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
normalBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getBorderLineStyle());
normalBorderColorBox = new ColorSelectBox(COLUMN_WIDTH);
normalBorderColorBox.setSelectObject(DEFAULT_STYLE.getBorderColor());
normalFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
normalFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily());
normalFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
normalFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getFontSize());
normalFontColorButton = new UIColorButton();
normalFontColorButton.setColor(DEFAULT_STYLE.getFontColor());
normalFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
normalFontItalicButton.setSelected(DEFAULT_STYLE.isFontItalic());
normalFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
normalFontBoldButton.setSelected(DEFAULT_STYLE.isFontBold());
JPanel opacityPane = new JPanel(new BorderLayout(0, 0));
JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0);
jp.add(normalOpacityDragBar);
jp.add(normalOpacitySpinner);
opacityPane.add(jp, BorderLayout.CENTER);
JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{{normalFontSizeComboBox, normalFontColorButton, normalFontItalicButton, normalFontBoldButton}},
new double[]{COLUMN_HEIGHT},
new double[]{p, p, p, p},
7, 0
);
double[] rowSize = {COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT};
double[] columnSize = {p, COLUMN_WIDTH, p};
JPanel normalStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT),
normalBackgroundColorBox
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT),
opacityPane,
new UILabel("%")
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT),
normalBorderWidthComBox
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT),
normalBorderColorBox
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT),
normalFontNameComboBox,
fontExtraPane
}
}, rowSize, columnSize, 5, 10);
normalStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
containerPane.setBorder(
GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Normal_Style"),
Color.decode("#2F8EF1"))
);
containerPane.add(normalStateStyleSettingsPanel);
return containerPane;
}
private JPanel createSelectedStateStylePanel() {
double p = TableLayout.PREFERRED;
selectedBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH);
selectedBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBackgroundColor());
selectedOpacityDragBar = new NumberDragBar(0, 100);
selectedOpacityDragBar.setValue(DEFAULT_STYLE.getSelectedOpacity());
selectedOpacityDragBar.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
selectedOpacitySpinner.setValue(selectedOpacityDragBar.getValue());
}
});
selectedOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getSelectedOpacity());
selectedOpacitySpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
selectedOpacityDragBar.setValue((int) selectedOpacitySpinner.getValue());
}
});
selectedBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
selectedBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getSelectedBorderLineStyle());
selectedBorderColorBox = new ColorSelectBox(COLUMN_WIDTH);
selectedBorderColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBorderColor());
selectedFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
selectedFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily());
selectedFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
selectedFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontSize());
selectedFontColorButton = new UIColorButton();
selectedFontColorButton.setColor(DEFAULT_STYLE.getSelectedFontColor());
selectedFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
selectedFontItalicButton.setSelected(DEFAULT_STYLE.isSelectedFontItalic());
selectedFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
selectedFontBoldButton.setSelected(DEFAULT_STYLE.isSelectedFontBold());
JPanel opacityPane = new JPanel(new BorderLayout(0, 0));
JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0);
jp.add(selectedOpacityDragBar);
jp.add(selectedOpacitySpinner);
opacityPane.add(jp, BorderLayout.CENTER);
JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{{selectedFontSizeComboBox, selectedFontColorButton, selectedFontItalicButton, selectedFontBoldButton}},
new double[]{COLUMN_HEIGHT},
new double[]{p, p, p, p},
7, 0
);
double[] rowSize = {COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT};
double[] columnSize = {p, COLUMN_WIDTH, p};
JPanel selectedStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT),
selectedBackgroundColorBox
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT),
opacityPane,
new UILabel("%")
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT),
selectedBorderWidthComBox
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT),
selectedBorderColorBox
},
{
new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT),
selectedFontNameComboBox,
fontExtraPane
}
}, rowSize, columnSize, 5, 10);
selectedStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
containerPane.setBorder(
GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Selected_Style"),
Color.decode("#2F8EF1"))
);
containerPane.add(selectedStateStyleSettingsPanel);
return containerPane;
}
@Override
public void populateBean(MobileBookMarkStyle ob) {
SidebarMobileBookMarkStyle style = null;
if (ob instanceof SidebarMobileBookMarkStyle) {
style = (SidebarMobileBookMarkStyle) ob;
}
if (style == null) {
return;
}
buttonWidthSpinner.setValue(style.getWidth());
buttonHeightSpinner.setValue(style.getHeight());
buttonGapSpinner.setValue(style.getGap());
buttonBorderRadiusSpinner.setValue(style.getBorderRadius());
normalBackgroundColorBox.setSelectObject(style.getBackgroundColor());
normalOpacityDragBar.setValue(style.getOpacity());
normalOpacitySpinner.setValue(style.getOpacity());
normalBorderWidthComBox.setSelectedLineStyle(style.getBorderLineStyle());
normalBorderColorBox.setSelectObject(style.getBorderColor());
normalFontNameComboBox.setSelectedItem(style.getFontFamily());
normalFontSizeComboBox.setSelectedItem(style.getFontSize());
normalFontColorButton.setColor(style.getFontColor());
normalFontItalicButton.setSelected(style.isFontItalic());
normalFontBoldButton.setSelected(style.isFontBold());
selectedBackgroundColorBox.setSelectObject(style.getSelectedBackgroundColor());
selectedOpacityDragBar.setValue(style.getSelectedOpacity());
selectedOpacitySpinner.setValue(style.getSelectedOpacity());
selectedBorderWidthComBox.setSelectedLineStyle(style.getSelectedBorderLineStyle());
selectedBorderColorBox.setSelectObject(style.getSelectedBorderColor());
selectedFontNameComboBox.setSelectedItem(style.getSelectedFontFamily());
selectedFontSizeComboBox.setSelectedItem(style.getSelectedFontSize());
selectedFontColorButton.setColor(style.getSelectedFontColor());
selectedFontItalicButton.setSelected(style.isSelectedFontItalic());
selectedFontBoldButton.setSelected(style.isSelectedFontBold());
}
@Override
public MobileBookMarkStyle updateBean() {
SidebarMobileBookMarkStyle style = new SidebarMobileBookMarkStyle();
style.setWidth((int) buttonWidthSpinner.getValue());
style.setHeight((int) buttonHeightSpinner.getValue());
style.setGap((int) buttonGapSpinner.getValue());
style.setBorderRadius((int) buttonBorderRadiusSpinner.getValue());
style.setBackgroundColor(normalBackgroundColorBox.getSelectObject());
style.setOpacity((int) normalOpacitySpinner.getValue());
style.setBorderLineStyle(normalBorderWidthComBox.getSelectedLineStyle());
style.setBorderColor(normalBorderColorBox.getSelectObject());
if (normalFontNameComboBox.getSelectedItem() != null) {
style.setFontFamily((String) normalFontNameComboBox.getSelectedItem());
}
if (normalFontSizeComboBox.getSelectedItem() != null) {
style.setFontSize((Integer) normalFontSizeComboBox.getSelectedItem());
}
style.setFontColor(normalFontColorButton.getColor());
style.setFontItalic(normalFontItalicButton.isSelected());
style.setFontBold(normalFontBoldButton.isSelected());
style.setSelectedBackgroundColor(selectedBackgroundColorBox.getSelectObject());
style.setSelectedOpacity((int) selectedOpacitySpinner.getValue());
style.setSelectedBorderLineStyle(selectedBorderWidthComBox.getSelectedLineStyle());
style.setSelectedBorderColor(selectedBorderColorBox.getSelectObject());
if (selectedFontNameComboBox.getSelectedItem() != null) {
style.setSelectedFontFamily((String) selectedFontNameComboBox.getSelectedItem());
}
if (selectedFontSizeComboBox.getSelectedItem() != null) {
style.setSelectedFontSize((Integer) selectedFontSizeComboBox.getSelectedItem());
}
style.setSelectedFontColor(selectedFontColorButton.getColor());
style.setSelectedFontItalic(selectedFontItalicButton.isSelected());
style.setSelectedFontBold(selectedFontBoldButton.isSelected());
return style;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

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

Loading…
Cancel
Save