Browse Source

Merge pull request #733 in DESIGN/design from ~NEIL/design:feature/10.0 to feature/10.0

* commit '5cc70c3e2e332ea5087718278b2de93be63c0d88': (93 commits)
  KERNEL-216 JSON全部改为jackson实现
  REPORT-12555 设计器重命名BUG
  REPORT-14020 可以重复打开设计器 调试的代码上次误传了
  记录次数bugfix
  每页发送成功后更新下最后发送时间
  合并发送,去重; 每次query 200条,放入内存,发送成功再进行新的请求
  REPORT-13999 公式增强编辑插件兼容.
  REPORT-13074 远程设计向下兼容 修改弹窗大小,以适配文字。
  REPORT-13573 远程预览报表数据集,会把报表传到服务端,报表比较大,会有性能问题,裁剪一下报表,只把需要的部分发过去。
  REPORT-10829  装了日志插件后设计器无法关闭
  删除调试信息
  REPORT-13895 release设计器启动时异步加载模板后,目录内容不断刷新
  REPORT-13902 错误的test依赖, 先移出来.
  切换事件监听优先级
  load 场景下 模板内存优化结果的处理
  REPORT-13202 包含插件控件的模板切换环境后存储出错
  REPORT-12718 设计器漏传了.
  无JIRA任务 去掉httpclient的使用
  REPORT-13802
  REPORT-13802
  ...
research/10.0
neil 6 years ago
parent
commit
d48bdcc531
  1. 170
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  2. 2
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 65
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 6
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  5. 38
      designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java
  6. 3
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  7. 26
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  8. 8
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JNDIDefPane.java
  9. 5
      designer-base/src/main/java/com/fr/design/designer/TargetComponent.java
  10. 4
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  11. 2
      designer-base/src/main/java/com/fr/design/extra/PluginsReaderFromStore.java
  12. 92
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  13. 5
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  14. 63
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  15. 69
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  16. 327
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  17. 55
      designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java
  18. 45
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractRightSelectionHandlerProvider.java
  19. 16
      designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java
  20. 14
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  21. 7
      designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java
  22. 4
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  23. 11
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  24. 11
      designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java
  25. 81
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  26. 27
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  27. 2
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  28. 46
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  29. 6
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java
  30. 9
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
  31. 10
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  32. 25
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java
  33. 8
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java
  34. 4
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java
  35. 2
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SliderStyleDefinePane.java
  36. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/StyleDefinePaneWithSelectConf.java
  37. 5
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java
  38. 10
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java
  39. 21
      designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java
  40. 21
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  41. 24
      designer-base/src/main/java/com/fr/design/style/color/PickColorButtonFactory.java
  42. 12
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  43. 36
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  44. 62
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java
  45. 2
      designer-base/src/main/resources/com/fr/design/insert/formula/variable/cn/servletURL.txt
  46. 2
      designer-base/src/main/resources/com/fr/design/insert/formula/variable/en/servletURL.txt
  47. 76
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java
  48. 8
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkNorthPane.java
  49. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartDatapointLabelPane.java
  50. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/CustomDefaultSeriesPane.java
  51. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/CustomTypeConditionSeriesPane.java
  52. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/LineSeriesPane.java
  53. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/RadarSeriesPane.java
  54. 5
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  55. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  56. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/format/CategoryNameFormatPaneWithCheckBox.java
  57. 11
      designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java
  58. 2
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java
  59. 10
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java
  60. 16
      designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java
  61. 66
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  62. 4
      designer-form/src/main/java/com/fr/design/designer/creator/ErrorCreator.java
  63. 12
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  64. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java
  65. 13
      designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java
  66. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  67. 8
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  68. 30
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  69. 35
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  70. 187
      designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java
  71. 56
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java
  72. 11
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  73. 11
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  74. 5
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  75. 2
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java
  76. 29
      designer-form/src/test/java/com/fr/form/ui/WidgetNameCopyTest.java
  77. 22
      designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java
  78. 75
      designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java
  79. 48
      designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java
  80. 2
      designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java
  81. 3
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  82. 314
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  83. 11
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  84. 6
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  85. 244
      designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java
  86. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  87. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java
  88. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  89. 11
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  90. 12
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  91. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  92. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java
  93. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  94. 18
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java
  95. 82
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  96. 16
      designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java
  97. 2
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java
  98. 4
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  99. 6
      designer-realize/src/main/java/com/fr/grid/selection/FloatSelection.java
  100. 36
      designer-realize/src/main/java/com/fr/grid/selection/Selection.java
  101. Some files were not shown because too many files have changed in this diff Show More

170
designer-base/src/main/java/com/fr/design/DesignModelAdapter.java

@ -3,6 +3,8 @@ package com.fr.design;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateProvider; import com.fr.design.mainframe.JTemplateProvider;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -14,68 +16,159 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 当前的设计器模式 * 设计器模式 FormModel or WorkBookModel
* <p>
* 指的是编辑的模板是普通报表还是决策报表
* *
* @author zhou * @author zhou
* @since 2012-7-26上午11:24:54 * @since 2012-7-26上午11:24:54
*/ */
public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplateProvider> { public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplateProvider<T>> {
/**
* 当前的设计模式 FormModel or WorkBookModel
*/
private static DesignModelAdapter<?, ?> currentModelAdapter; private static DesignModelAdapter<?, ?> currentModelAdapter;
/**
* 模板
*/
protected S jTemplate; protected S jTemplate;
/**
* 全部的参数包括全局参数模板参数和数据集参数
*/
private Parameter[] parameters;
/**
* 数据集参数
*/
private Parameter[] tableDataParameters;
/**
* 模板参数
*/
private Parameter[] templateParameters;
public DesignModelAdapter(S jTemplate) { public DesignModelAdapter(S jTemplate) {
this.jTemplate = jTemplate; this.jTemplate = jTemplate;
setCurrentModelAdapter(this); updateCachedParameter();
setCurrentModelAdapter(this);
}
public static void setCurrentModelAdapter(DesignModelAdapter<?, ?> model) {
currentModelAdapter = model;
}
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return currentModelAdapter;
} }
/**
* 获取当前编辑的模板
*
* @return template
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
* @see HistoryTemplateListCache#getCurrentEditingTemplate()
* @deprecated use {@link HistoryTemplateListCache#setCurrentEditingTemplate(JTemplate)} instead
*/
@Deprecated
public S getjTemplate() { public S getjTemplate() {
return jTemplate; return jTemplate;
} }
/**
* 设置当前编辑的模板
* 不要脱离上下文直接调用
*
* @param jTemplate jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
* @deprecated use {@link HistoryTemplateListCache#setCurrentEditingTemplate(JTemplate)} instead
*/
@Deprecated
public void setjTemplate(S jTemplate) { public void setjTemplate(S jTemplate) {
this.jTemplate = jTemplate; this.jTemplate = jTemplate;
} }
public T getBook() { public T getBook() {
return (T) ((JTemplate) jTemplate).getTarget(); return jTemplate.getTarget();
} }
public static void setCurrentModelAdapter(DesignModelAdapter<?, ?> model) {
currentModelAdapter = model;
}
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return currentModelAdapter;
}
/** /**
* 响应目标改变事件. * 响应正在编辑的模板改变事件.
*/ */
public void fireTargetModified() { public void fireTargetModified() {
((JTemplate) this.jTemplate).fireTargetModified(); this.jTemplate.fireTargetModified();
} }
/**
* 获取悬浮元素名称数组
*
* @return String[] 悬浮元素名称数组
*/
public String[] getFloatNames() { public String[] getFloatNames() {
return new String[0]; return new String[0];
} }
/**
* 获取编辑模板的所有参数
* <p>
* 由于在参数面板拖动过程中频繁获取
* 远程设计时数据集参数rpc 调用需要考虑网络等因素,因此会比较缓慢,引起参数面板拖动卡顿,
* 所以缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板的所有参数
*/
public Parameter[] getParameters() { public Parameter[] getParameters() {
return new Parameter[0]; return parameters == null ? new Parameter[0] : parameters;
} }
// 报表参数 /**
* 模板参数报表参数
* <p>
* 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板参数
* @deprecated use {@link DesignModelAdapter#getTemplateParameters()} instead
*/
@Deprecated
public Parameter[] getReportParameters() { public Parameter[] getReportParameters() {
return new Parameter[0]; return getTableDataParameters();
}
/**
* 模板参数报表参数
* <p>
* 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板参数
*/
public Parameter[] getTemplateParameters() {
return templateParameters == null ? new Parameter[0] : templateParameters;
} }
/** /**
* 数据源参数 * 数据源参数
* <p>
* 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存
* *
* @return * @return Parameter[] 数据源参数
*/ */
public Parameter[] getTableDataParameters() { public Parameter[] getTableDataParameters() {
return new Parameter[0]; return tableDataParameters == null ? new Parameter[0] : tableDataParameters;
}
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
return renameTableData(oldName, newName, true);
} }
/** /**
@ -101,17 +194,6 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
return true; return true;
} }
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
return renameTableData(oldName, newName, true);
}
/** /**
* 重命名tabledata * 重命名tabledata
* *
@ -128,10 +210,23 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
} }
} }
public abstract Widget[] getLinkableWidgets() ; public abstract Widget[] getLinkableWidgets();
public abstract List<WidgetName> getWidgetsName(); public abstract List<WidgetName> getWidgetsName();
/**
* 更新缓存的参数
*/
public void updateCachedParameter() {
// 全部参数
this.parameters = getLatestParameters();
// 数据及参数
this.tableDataParameters = getLatestTableDataParameters();
// 模板参数
this.templateParameters = getLatestTemplateParameters();
}
/** /**
* 环境改变. * 环境改变.
*/ */
@ -146,4 +241,19 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
* 控件配置改变. * 控件配置改变.
*/ */
public abstract void widgetConfigChanged(); public abstract void widgetConfigChanged();
/**
* 获取变更后的模板参数
*/
protected abstract Parameter[] getLatestTemplateParameters();
/**
* 获取变更后的数据集参数
*/
protected abstract Parameter[] getLatestTableDataParameters();
/**
* 获取变更后的全部参数
*/
protected abstract Parameter[] getLatestParameters();
} }

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

@ -112,7 +112,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false; private boolean supportCellEditorDef = false;
private boolean isDragPermited = false; private boolean isDragPermited = false;
private Locale language = Locale.SIMPLIFIED_CHINESE; private Locale language = Locale.getDefault();
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容 //2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true; private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT; private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;

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

@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -15,19 +16,25 @@ import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
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;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { public class EnvChangeEntrance {
@ -90,15 +97,21 @@ public class EnvChangeEntrance {
}); });
return false; return false;
} }
// 如果版本不一致,且确认 不继续 连接,这里返回 false.
if (!versionCheckAndConfirm(selectedEnv)) {
return false;
}
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName); DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame(); DesignUtils.refreshDesignerFrame();
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray //初始化一下serverTray
@ -138,6 +151,50 @@ public class EnvChangeEntrance {
return true; return true;
} }
/**
* 切换远程环境之前进行版本检测当版本不一致的时候提示
* 当用户确认选择 ok 才继续
*
* @param selectedEnv 选择的环境
* @return 是否一致
* 1. 非远程环境 返回 true
* 2. 远程环境
* 2.1 不匹配
* 2.1.1 当选择 ok 返回 true
* 2.1.2 当选择 no, 返回 false
* 2.2 匹配 返回 true
* @throws Exception 异常
*/
private boolean versionCheckAndConfirm(DesignerWorkspaceInfo selectedEnv) throws Exception {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo info = selectedEnv.getConnection();
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return true;
}
final List<Integer> result = new ArrayList<>(1);
PopTipStrategy.NOW.showTip(new PopTip() {
@Override
public void show() {
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
int choice = JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistency"),
UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1);
result.add(choice);
}
});
// 只有选择 yes , 这里的值才为 0, 返回 true
// 否着返回 false, 将不进行下面的连接操作。
return result.size() != 0 && result.get(0) == 0;
}
return true;
}
/** /**
* 编辑items * 编辑items
* *

6
designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java

@ -9,9 +9,9 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.exception.RemoteDesignPermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.io.exporter.ExporterKey;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.DesignExportType; import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.ExporterKey;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -178,7 +178,7 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(), DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"), Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"),
null, UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE, JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon") UIManager.getIcon("OptionPane.errorIcon")
); );
@ -189,7 +189,7 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(), DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path, Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path,
null, UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE, JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon") UIManager.getIcon("OptionPane.errorIcon")
); );

38
designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java

@ -121,7 +121,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
JoinCondition newJoinCondition = new JoinCondition(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR, liteCondition); JoinCondition newJoinCondition = new JoinCondition(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR, liteCondition);
ExpandMutableTreeNode parentTreeNode = getParentTreeNode(); ExpandMutableTreeNode parentTreeNode = getParentTreeNode();
boolean result = isExistedInParentTreeNode(parentTreeNode, newJoinCondition); boolean result = isExistedInParentTreeNode(parentTreeNode, liteCondition, false);
if (result) { if (result) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed")); com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed"));
@ -162,7 +162,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
@Override @Override
public void mouseExited(MouseEvent evt) { public void mouseExited(MouseEvent evt) {
GUICoreUtils.setEnabled(conditionCardPane, conditionCardPane.isEnabled()); GUICoreUtils.setEnabled(conditionCardPane, conditionCardPane.isEnabled());
} }
}; };
@ -596,6 +596,8 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
oldJoinCondition.setJoin(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR); oldJoinCondition.setJoin(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR);
Condition oldLiteCondition = oldJoinCondition.getCondition(); Condition oldLiteCondition = oldJoinCondition.getCondition();
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
// peter:如果当前选中的是ListCondition,只要改变Join为AND或者OR,直接返回. // peter:如果当前选中的是ListCondition,只要改变Join为AND或者OR,直接返回.
if (oldLiteCondition != null && !(oldLiteCondition instanceof ListCondition)) { if (oldLiteCondition != null && !(oldLiteCondition instanceof ListCondition)) {
// peter:先获得当前的LiteCondition. // peter:先获得当前的LiteCondition.
@ -605,13 +607,18 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
} else { } else {
liteCondition = new FormulaCondition(formulaTextArea.getText()); liteCondition = new FormulaCondition(formulaTextArea.getText());
} }
//修改的时候加入判断条件重复 REPORT-13441
boolean result = isExistedInParentTreeNode(parentTreeNode, liteCondition, true);
if (result) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed"));
return;
}
oldJoinCondition.setCondition(liteCondition); oldJoinCondition.setCondition(liteCondition);
} }
// peter:需要reload parent // peter:需要reload parent
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
defaultTreeModel.reload(parentTreeNode); defaultTreeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree); parentTreeNode.expandCurrentTreeNode(conditionsTree);
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(selectedTreeNode)); conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(selectedTreeNode));
@ -745,22 +752,31 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
return parentTreeNode; return parentTreeNode;
} }
private boolean isExistedInParentTreeNode(ExpandMutableTreeNode parentTreeNode, JoinCondition newJoinCondition) { private boolean isExistedInParentTreeNode(ExpandMutableTreeNode parentTreeNode, Condition liteCondition, boolean isModify) {
if (parentTreeNode == null) { if (parentTreeNode == null) {
return false; return false;
} }
JoinCondition parentJoinCondition = (JoinCondition) parentTreeNode.getUserObject(); JoinCondition parentJoinCondition = (JoinCondition) parentTreeNode.getUserObject();
Condition parentLiteCondition = parentJoinCondition.getCondition(); Condition parentLiteCondition = parentJoinCondition.getCondition();
Object oldJoinCondition = null;
//获取当前选中的条件用于修改判断
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath != null) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
oldJoinCondition = selectedTreeNode.getUserObject();
}
if (parentLiteCondition instanceof ListCondition) { if (parentLiteCondition instanceof ListCondition) {
// peter:在添加UserObject的节点. // peter:在添加UserObject的节点.
for (int i = 0; i < parentTreeNode.getChildCount(); i++) { for (int i = 0; i < parentTreeNode.getChildCount(); i++) {
ExpandMutableTreeNode tempTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildAt(i); ExpandMutableTreeNode tempTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildAt(i);
Object tempObject = tempTreeNode.getUserObject(); Object tempObject = tempTreeNode.getUserObject();
if (tempObject instanceof JoinCondition) { //修改的时候需要排除所选条件,和其他条件比较。增加的时候全盘比较
if (tempObject instanceof JoinCondition && isModify ? (!tempObject.equals(oldJoinCondition)) : true) {
JoinCondition tempJoinCondition = (JoinCondition) tempObject; JoinCondition tempJoinCondition = (JoinCondition) tempObject;
if (ComparatorUtils.equals(tempJoinCondition, newJoinCondition)) { //条件内容一样就视为相同条件,join类型无关
if (ComparatorUtils.equals(tempJoinCondition.getCondition(), liteCondition)) {
return true; return true;
} }
} }
@ -941,7 +957,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
@Override @Override
public Condition updateBean() { public Condition updateBean() {
// Samuel:先按modifybutton // Samuel:先按modifybutton
modify(); //modify(); REPORT-13442 需要点修改按钮才能修改
// peter: 先删除所有的节点 // peter: 先删除所有的节点
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.conditionsTree.getModel(); DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.conditionsTree.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
@ -963,9 +979,9 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
JoinCondition joinCondition = (JoinCondition) rootTreeNode.getUserObject(); JoinCondition joinCondition = (JoinCondition) rootTreeNode.getUserObject();
Condition newCondition = joinCondition.getCondition(); Condition newCondition = joinCondition.getCondition();
//clone(),防止多个条件分组使用同一个condition对象 //clone(),防止多个条件分组使用同一个condition对象
try{ try {
newCondition = (Condition)joinCondition.getCondition().clone(); newCondition = (Condition) joinCondition.getCondition().clone();
}catch (CloneNotSupportedException e){ } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return newCondition; return newCondition;

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

@ -4,6 +4,7 @@ import com.fr.base.FRContext;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.core.DataCoreXmlUtils;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
@ -444,7 +445,7 @@ public abstract class DesignTableDataManager {
parameter.setValue(parameterMap.get(parameter.getName())); parameter.setValue(parameterMap.get(parameter.getName()));
} }
} }
return DataOperator.getInstance().previewTableData(tableDataSource, tabledata, parameterMap, rowCount); return DataOperator.getInstance().previewTableData(TableDataSourceTailor.extractTableData(tableDataSource), tabledata, parameterMap, rowCount);
} catch (Exception e) { } catch (Exception e) {
throw new TableDataException(e.getMessage(), e); throw new TableDataException(e.getMessage(), e);
} finally { } finally {

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

@ -17,6 +17,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -36,8 +37,8 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private JDialog dialog; private JDialog dialog;
private UILabel uiLabel; private UILabel uiLabel;
// 编码转换. // 编码转换.
private UIComboBox newCharSetComboBox; private UIComboBox charSetComboBox;
private String oirginalCharSet = null; private String originalCharSet = null;
// Database pane // Database pane
public DatabaseConnectionPane() { public DatabaseConnectionPane() {
@ -50,7 +51,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
String[] defaultEncode = new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto")}; String[] defaultEncode = new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto")};
newCharSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY)); charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
@ -72,7 +73,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
new ModLineBorder(ModLineBorder.TOP), new ModLineBorder(ModLineBorder.TOP),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced") com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced")
)); ));
chartSetPane.add(GUICoreUtils.createNamedPane(newCharSetComboBox, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_New_Charset") + ":")); chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
} }
protected abstract JPanel mainPanel(); protected abstract JPanel mainPanel();
@ -81,8 +82,12 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override @Override
public void populateBean(com.fr.data.impl.Connection ob) { public void populateBean(com.fr.data.impl.Connection ob) {
this.oirginalCharSet = ob.getOriginalCharsetName(); this.originalCharSet = ob.getOriginalCharsetName();
this.newCharSetComboBox.setSelectedItem(ob.getNewCharsetName()); if (StringUtils.isBlank(originalCharSet)) {
this.charSetComboBox.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto"));
} else {
this.charSetComboBox.setSelectedItem(ob.getOriginalCharsetName());
}
populateSubDatabaseConnectionBean((E) ob); populateSubDatabaseConnectionBean((E) ob);
} }
@ -93,11 +98,14 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public com.fr.data.impl.Connection updateBean() { public com.fr.data.impl.Connection updateBean() {
E ob = updateSubDatabaseConnectionBean(); E ob = updateSubDatabaseConnectionBean();
ob.setOriginalCharsetName(this.oirginalCharSet); ob.setOriginalCharsetName(this.originalCharSet);
if (this.newCharSetComboBox.getSelectedIndex() == 0) { if (this.charSetComboBox.getSelectedIndex() == 0) {
ob.setNewCharsetName(null); ob.setNewCharsetName(null);
ob.setOriginalCharsetName(null);
} else { } else {
ob.setNewCharsetName((String) this.newCharSetComboBox.getSelectedItem()); ob.setNewCharsetName(EncodeConstants.ENCODING_GBK);
ob.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem()));
} }
return ob; return ob;

8
designer-base/src/main/java/com/fr/design/data/datapane/connect/JNDIDefPane.java

@ -125,7 +125,7 @@ public class JNDIDefPane extends JPanel {
} }
// Properties. // Properties.
Hashtable<String, String> contextHashtable = jndiDatabase.getContextHashtable(); Map<String, String> contextHashtable = jndiDatabase.getContextHashtable();
Object INITIAL_CONTEXT_FACTORY = contextHashtable.get(Context.INITIAL_CONTEXT_FACTORY); Object INITIAL_CONTEXT_FACTORY = contextHashtable.get(Context.INITIAL_CONTEXT_FACTORY);
this.JNDIFactoryComboBox.setSelectedItem(INITIAL_CONTEXT_FACTORY == null ? "" : INITIAL_CONTEXT_FACTORY); this.JNDIFactoryComboBox.setSelectedItem(INITIAL_CONTEXT_FACTORY == null ? "" : INITIAL_CONTEXT_FACTORY);
@ -148,7 +148,7 @@ public class JNDIDefPane extends JPanel {
populateContextAttributes(contextHashtable, this.APPLET_TF, Context.APPLET); populateContextAttributes(contextHashtable, this.APPLET_TF, Context.APPLET);
} }
private void populateContextAttributes(Hashtable<String, String> properties, UITextField textField, String contextAttr) { private void populateContextAttributes(Map<String, String> properties, UITextField textField, String contextAttr) {
String PROVIDER_URL = properties.get(contextAttr); String PROVIDER_URL = properties.get(contextAttr);
if (PROVIDER_URL != null) { if (PROVIDER_URL != null) {
textField.setText(PROVIDER_URL); textField.setText(PROVIDER_URL);
@ -160,7 +160,7 @@ public class JNDIDefPane extends JPanel {
jndiDatabase.setJNDIName(this.jndiNameTextField.getText()); jndiDatabase.setJNDIName(this.jndiNameTextField.getText());
Hashtable<String, String> contextHashtable = jndiDatabase.getContextHashtable(); Map<String, String> contextHashtable = jndiDatabase.getContextHashtable();
String factoryString = (String)this.JNDIFactoryComboBox.getEditor().getItem(); String factoryString = (String)this.JNDIFactoryComboBox.getEditor().getItem();
if (factoryString != null && factoryString.trim().length() > 0) { if (factoryString != null && factoryString.trim().length() > 0) {
@ -186,7 +186,7 @@ public class JNDIDefPane extends JPanel {
return jndiDatabase; return jndiDatabase;
} }
private void updateContextAttributes(Hashtable<String, String> contextHashtable, UITextField textField, String contextAttr) { private void updateContextAttributes(Map<String, String> contextHashtable, UITextField textField, String contextAttr) {
String tValue = textField.getText(); String tValue = textField.getText();
if (tValue != null && tValue.trim().length() > 0) { if (tValue != null && tValue.trim().length() > 0) {
contextHashtable.put(contextAttr, tValue); contextHashtable.put(contextAttr, tValue);

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

@ -3,6 +3,7 @@ package com.fr.design.designer;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.mainframe.AuthorityEditPane; import com.fr.design.mainframe.AuthorityEditPane;
import com.fr.design.mainframe.JTemplateProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
@ -15,7 +16,7 @@ import javax.swing.JPanel;
/** /**
* 模板设计界面 * 模板设计界面
*/ */
public abstract class TargetComponent<T> extends JComponent { public abstract class TargetComponent<T> extends JComponent implements JTemplateProvider<T> {
private T target; private T target;
public TargetComponent(T t) { public TargetComponent(T t) {
@ -34,6 +35,7 @@ public abstract class TargetComponent<T> extends JComponent {
public abstract void stopEditing(); public abstract void stopEditing();
@Override
public T getTarget() { public T getTarget() {
return target; return target;
} }
@ -82,6 +84,7 @@ public abstract class TargetComponent<T> extends JComponent {
/** /**
* Fire template modified listeners. * Fire template modified listeners.
*/ */
@Override
public void fireTargetModified() { public void fireTargetModified() {
// Guaranteed to return a non-null array // Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList(); Object[] listeners = listenerList.getListenerList();

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

@ -104,7 +104,7 @@ public class PluginWebBridge {
for (String key : keySet) { for (String key : keySet) {
jsonObject.put(key, config.get(key).toString()); jsonObject.put(key, config.get(key).toString());
} }
} catch (JSONException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return jsonObject.toString(); return jsonObject.toString();
@ -349,7 +349,7 @@ public class PluginWebBridge {
try { try {
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(new JSONObject(info))); Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(new JSONObject(info)));
threadPoolExecutor.submit(task); threadPoolExecutor.submit(task);
} catch (JSONException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }

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

@ -74,7 +74,7 @@ public class PluginsReaderFromStore {
plugins.add(pluginView); plugins.add(pluginView);
} }
} }
} catch (JSONException e) { } catch (Exception e) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Read_Plugin_List_Error")); throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Read_Plugin_List_Error"));
} }
} }

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

@ -1,10 +1,14 @@
package com.fr.design.file; 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.IOFile;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -16,10 +20,14 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map;
/** /**
* 历史模板缓存 * 历史模板缓存
@ -58,6 +66,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
public void closeSelectedReport(JTemplate<?, ?> selected) { public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane(); DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected); DesignTableDataManager.closeTemplate(selected);
//直接关闭模板的时候退出权限编辑
if (DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().closeAuthorityEditing();
}
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }
@ -99,6 +111,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
return this.editingTemplate; return this.editingTemplate;
} }
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt; this.editingTemplate = jt;
//如果当前历史面板中没有 //如果当前历史面板中没有
@ -178,10 +194,13 @@ public class HistoryTemplateListCache implements CallbackEvent {
/** /**
* 判断是否打开过该模板 * 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板
* *
* @param filename 文件名 * @param filename 文件名
* @return 文件位置 * @return 文件位置
* @deprecated use HistoryTemplateListCache#contains(com.fr.design.mainframe.JTemplate) instead
*/ */
@Deprecated
public int contains(String filename) { public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) { for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath(); String historyPath = historyList.get(i).getPath();
@ -292,4 +311,77 @@ public class HistoryTemplateListCache implements CallbackEvent {
} }
return true; return true;
} }
/**
* 切换环境时暂存打开的模板内容key 是在历史中的indexvalue 是模板xml 内容byte[]
*/
private Map<Integer, byte[]> bytesMap;
/**
* 切换环境前将正在编辑的模板暂存起来并且在新环境中重新读取一遍暂存的不是模板文件的内容而是模板对象的内容
* <p>
* 防止新环境加载到的同名 Class 和模板对象中的 Class 不一致在新环境存储失败
*
* @see HistoryTemplateListCache#load()
*/
public void stash() {
FineLoggerFactory.getLogger().info("Env Change Template Stashing...");
if (bytesMap == null) {
bytesMap = new HashMap<Integer, byte[]>();
} else {
bytesMap.clear();
}
int size = historyList.size();
for (int i = 0; i < size; i++) {
JTemplate<?, ?> template = historyList.get(i);
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
target.export(outputStream);
bytesMap.put(i, outputStream.toByteArray());
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
FineLoggerFactory.getLogger().info("Env Change Template Stashed.");
}
/**
* 切换环境前将正在编辑的模板暂存起来后在新环境重新读取一遍
* <p>
* 防止新环境加载到的同名 Class 和模板对象中的 Class 不一致在新环境存储失败
*
* @see HistoryTemplateListCache#stash()
*/
public void load() {
FineLoggerFactory.getLogger().info("Env Change Template Loading...");
if (bytesMap != null && bytesMap.size() != 0) {
int size = historyList.size();
for (int i = 0; i < size; i++) {
try {
byte[] bytes = bytesMap.get(i);
// 可能有模板 stash 失败的情况,在 load 的时候不更新它
if (bytes == null) {
continue;
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
BaseBook target = historyList.get(i).getTarget();
if (target != null) {
// todo readStream 这个行为应该上升到 BaseBook 上
((IOFile) target).readStream(inputStream);
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
bytesMap.clear();
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
MutilTempalteTabPane.getInstance().repaint();
}
FineLoggerFactory.getLogger().info("Env Change Template Loaded.");
}
} }

5
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java

@ -1,6 +1,7 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
@ -60,6 +61,10 @@ public class HistoryTemplateListPane implements CallbackEvent {
return instead().getCurrentEditingTemplate(); return instead().getCurrentEditingTemplate();
} }
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
instead().setCurrentEditingTemplate(jt); instead().setCurrentEditingTemplate(jt);

63
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -18,7 +18,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.third.javax.annotation.Nonnull; import com.fr.third.javax.annotation.Nonnull;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
@ -206,8 +205,7 @@ public class MutilTempalteTabPane extends JComponent {
openedTemplate.remove(jTemplate); openedTemplate.remove(jTemplate);
closeFormat(jTemplate); closeFormat(jTemplate);
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate);
// release lock closeAndFreeLock(jTemplate);
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(jTemplate.getPath());
} }
} }
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -221,7 +219,6 @@ public class MutilTempalteTabPane extends JComponent {
if (openedTemplate.size() == 1) { if (openedTemplate.size() == 1) {
closeOther.setEnabled(false); closeOther.setEnabled(false);
} }
return closeOther; return closeOther;
} }
@ -676,9 +673,6 @@ public class MutilTempalteTabPane extends JComponent {
return; return;
} }
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getPath();
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing(); specifiedTemplate.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
@ -686,21 +680,29 @@ public class MutilTempalteTabPane extends JComponent {
if (returnVal == JOptionPane.YES_OPTION) { if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate(); specifiedTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} else if (returnVal == JOptionPane.NO_OPTION) { } else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} }
} else { } else {
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} }
} }
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate, @Nonnull String fileName) { private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock closeAndFreeLock(specifiedTemplate);
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath()); activePrevTemplateAfterClose();
activeTemplate(fileName); }
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) {
FILE file = template.getEditingFILE();
// 只有是环境内的文件,才执行释放锁
if (file != null && file.isEnvFile()) {
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
}
} }
/** /**
@ -723,11 +725,9 @@ public class MutilTempalteTabPane extends JComponent {
} }
/** /**
* 关闭掉一个模板之后该激活的Tab * 关闭掉一个模板之后激活新的待显示模板
*
* @param fileName 关闭掉一个模板之后该激活的Tab的文件名绝对路径
*/ */
private void activeTemplate(String fileName) { private void activePrevTemplateAfterClose() {
if (openedTemplate.isEmpty()) { if (openedTemplate.isEmpty()) {
//新建并激活模板 //新建并激活模板
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); DesignerContext.getDesignerFrame().addAndActivateJTemplate();
@ -736,23 +736,20 @@ public class MutilTempalteTabPane extends JComponent {
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
} else { } else {
//如果关闭的模板是当前选中的模板,则重新激活 // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
if (closeIconIndex == selectedIndex) { // selectIndex 没有变化,但是对应的模板已经变成了前一张模板
if (closeIconIndex == maxPaintIndex) { if (closeIconIndex == selectedIndex || isCloseCurrent) {
// 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界
if (closeIconIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex--; selectedIndex--;
} }
} else if (isCloseCurrent) { isCloseCurrent = false;
//不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活 }
if (selectedIndex > openedTemplate.size() - 1) { // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
selectedIndex -= 1; else {
if (selectedIndex < 0) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = 0; selectedIndex = HistoryTemplateListCache.getInstance().contains(template);
}
isCloseCurrent = false;
}
} else {
//如果关闭的模板不是当前选中的模板,则激活的模板不变
selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName);
} }
//如果是已后台关闭的模板,则重新打开文件 //如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate(); openedTemplate.get(selectedIndex).activeOldJTemplate();

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

@ -63,19 +63,19 @@ import java.util.Locale;
*/ */
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea;
protected RSyntaxTextArea formulaTextArea; private RSyntaxTextArea formulaTextArea;
protected UITextField keyWordTextField = new UITextField(18); private UITextField keyWordTextField = new UITextField(18);
protected int currentPosition = 0; private int currentPosition = 0;
protected int beginPosition = 0; private int beginPosition = 0;
protected int insertPosition = 0; private int insertPosition = 0;
protected JList tipsList; private JList tipsList;
protected DefaultListModel listModel = new DefaultListModel(); protected DefaultListModel listModel = new DefaultListModel();
protected int ifHasBeenWriten = 0; private int ifHasBeenWriten = 0;
protected DefaultListModel functionTypeListModel = new DefaultListModel(); private DefaultListModel functionTypeListModel = new DefaultListModel();
protected QuickList functionTypeList; private QuickList functionTypeList;
protected DefaultListModel functionNameModel; private DefaultListModel functionNameModel;
protected JList functionNameList; private JList functionNameList;
public FormulaPane() { public FormulaPane() {
initComponents(); initComponents();
@ -184,6 +184,18 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected void initComponents() { protected void initComponents() {
this.setLayout(new BorderLayout(4, 4)); this.setLayout(new BorderLayout(4, 4));
initTextPane();
initTipsPane();
initVariableTreeAndDescriptionArea();
}
private void initVariableTreeAndDescriptionArea() {
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
}
private void initTextPane() {
// text // text
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(textPane, BorderLayout.CENTER); this.add(textPane, BorderLayout.CENTER);
@ -199,7 +211,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER); textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER);
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH); textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH);
initTipsPane();
UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid")); UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid"));
checkValidButton.addActionListener(checkValidActionListener); checkValidButton.addActionListener(checkValidActionListener);
@ -209,8 +220,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST); checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST);
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST); checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST);
extendCheckBoxPane(checkBoxPane); extendCheckBoxPane(checkBoxPane);
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
} }
@ -218,7 +227,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
protected void configFormulaArea() { private void configFormulaArea() {
formulaTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_FORMULA); formulaTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_FORMULA);
formulaTextArea.setAnimateBracketMatching(true); formulaTextArea.setAnimateBracketMatching(true);
formulaTextArea.setAntiAliasingEnabled(true); formulaTextArea.setAntiAliasingEnabled(true);
@ -313,7 +322,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
} }
protected void fixFunctionNameList() { private void fixFunctionNameList() {
if (tipsList.getSelectedValue() != null) { if (tipsList.getSelectedValue() != null) {
int signOfContinue = 1; int signOfContinue = 1;
int indexOfFunction = 0; int indexOfFunction = 0;
@ -346,7 +355,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
protected int getBeginPosition() { private int getBeginPosition() {
int i = currentPosition; int i = currentPosition;
String textArea = formulaTextArea.getText(); String textArea = formulaTextArea.getText();
for (; i > 0; i--) { for (; i > 0; i--) {
@ -361,7 +370,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return i; return i;
} }
protected void firstStepToFindTips(int theBeginPosition) { private void firstStepToFindTips(int theBeginPosition) {
String textArea = formulaTextArea.getText(); String textArea = formulaTextArea.getText();
if (currentPosition > 0 && theBeginPosition < currentPosition) { if (currentPosition > 0 && theBeginPosition < currentPosition) {
@ -443,7 +452,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
/** /**
* Apply text. * Apply text.
*/ */
public void applyText(String text) { private void applyText(String text) {
if (text == null || text.length() <= 0) { if (text == null || text.length() <= 0) {
return; return;
} }
@ -541,7 +550,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
// check valid // check valid
protected ActionListener checkValidActionListener = new ActionListener() { private ActionListener checkValidActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// Execute Formula default cell element. // Execute Formula default cell element.
@ -579,7 +588,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private JTree variablesTree; private JTree variablesTree;
private UITextArea descriptionTextArea; private UITextArea descriptionTextArea;
public VariableTreeAndDescriptionArea() { VariableTreeAndDescriptionArea() {
this.initComponents(); this.initComponents();
} }
@ -802,13 +811,15 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private void initComponents() { private void initComponents() {
this.setLayout(new BorderLayout(4, 4)); this.setLayout(new BorderLayout(4, 4));
// Function initVariablesTree();
initFunctionPane();
}
private void initFunctionPane() {
JPanel functionPane = new JPanel(new BorderLayout(4, 4)); JPanel functionPane = new JPanel(new BorderLayout(4, 4));
this.add(functionPane, BorderLayout.WEST); this.add(functionPane, BorderLayout.WEST);
initFunctionTypeList(functionPane); initFunctionTypeList(functionPane);
initFunctionNameList(functionPane); initFunctionNameList(functionPane);
initVariablesTree();
// 选择:
functionTypeList.setSelectedIndex(0); functionTypeList.setSelectedIndex(0);
} }
@ -959,7 +970,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private Icon icon; private Icon icon;
private String[] subNodes = new String[0]; private String[] subNodes = new String[0];
public TextFolderUserObject(String text, Icon icon, String[] subNodes) { TextFolderUserObject(String text, Icon icon, String[] subNodes) {
this.text = text; this.text = text;
this.icon = icon; this.icon = icon;
this.subNodes = subNodes; this.subNodes = subNodes;
@ -986,11 +997,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public static class TextUserObject { public static class TextUserObject {
public TextUserObject(String text) { TextUserObject(String text) {
this(text, text); this(text, text);
} }
public TextUserObject(String text, String displayText) { TextUserObject(String text, String displayText) {
this.text = text; this.text = text;
this.displayText = displayText; this.displayText = displayText;
} }
@ -999,7 +1010,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return this.text; return this.text;
} }
public String getDisplayText() { String getDisplayText() {
return this.displayText; return this.displayText;
} }

327
designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java

@ -12,7 +12,8 @@ import com.fr.function.RANGE;
import com.fr.function.SUM; import com.fr.function.SUM;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
@ -23,20 +24,100 @@ import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function; import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef; import com.fr.stable.script.FunctionDef;
import javax.swing.DefaultListModel;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.swing.DefaultListModel; public final class FunctionConstants {
public abstract class FunctionConstants { public static FunctionGroup PLUGIN = getPluginFunctionGroup();
public static FunctionGroup CUSTOM = getCustomFunctionGroup();
public static NameAndFunctionList COMMON = getCommonFunctionList();
public static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray();
public static FunctionGroup ALL = getAllFunctionGroup();
static {
loadEmbededFunctions();
}
/** /**
* Don't let anyone instantiate this class.
*/
private FunctionConstants() {}
private static void loadEmbededFunctions() {
String pkgName = "com.fr.function";
Class<Function> iface = Function.class;
ClassLoader classloader = iface.getClassLoader();
Enumeration<URL> urlEnumeration = null;
try {
urlEnumeration = classloader.getResources(pkgName.replace('.', '/'));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
return;
}
while (urlEnumeration.hasMoreElements()) {
URL url = urlEnumeration.nextElement();
String classFilePath = url.getFile();
/*
* alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理
* 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理
*/
try {
classFilePath = URLDecoder.decode(classFilePath, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e1) {
FRContext.getLogger().error(e1.getMessage(), e1);
}
FRContext.getLogger().info("ClassFilePath:" + classFilePath);
if (isCustomFormulaPath(classFilePath)) {
continue;
}
for (String fileName : findClassNamesUnderFilePath(classFilePath)) {
try {
Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6));
if (StableUtils.classInstanceOf(cls, iface)) {
Function inst;
inst = (Function)cls.newInstance();
for (NameAndTypeAndFunctionList EMBFUNCTION : EMBFUNCTIONS) {
if (EMBFUNCTION.test(inst)) {
break;
}
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ignore) {
} catch (Throwable e) {
// 不要因为个别公式加载失败,而导致整个函数面板无法启动
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
}
private static boolean isCustomFormulaPath(String classFilePath) {
return !isJarPath(classFilePath) && isNotDebugMode();
}
private static boolean isNotDebugMode() {
return GeneralUtils.readBuildNO().contains("-");
}
private static boolean isJarPath(String classFilePath) {
return classFilePath.contains("!/");
}
/**
* 将函数分组插件中的函数添加到对应的列表中 * 将函数分组插件中的函数添加到对应的列表中
* @param listModel * @param listModel
*/ */
@ -75,98 +156,6 @@ public abstract class FunctionConstants {
}; };
} }
public static FunctionGroup PLUGIN = new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Formula_Plugin");
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionDef[] fs = ExtraClassManager.getInstance().getFunctionDef();
int count = fs.length;
FunctionDefNAD[] nads = new FunctionDefNAD[count];
for (int i = 0; i < count; i ++) {
nads[i] = new FunctionDefNAD(fs[i]);
}
return nads;
}
};
public static FunctionGroup CUSTOM = new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Custom_Function");
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionConfig funtionManager = FunctionConfig.getInstance();
if (funtionManager != null) {
int functionDefCount = funtionManager.getFunctionDefCount();
FunctionDefNAD[] nads = new FunctionDefNAD[functionDefCount];
for (int i = 0; i < functionDefCount; i++) {
nads[i] = new FunctionDefNAD(funtionManager.getFunctionDef(i));
}
return nads;
}
return new NameAndDescription[0];
}
};
public static NameAndFunctionList COMMON = new NameAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Most_Recently_Used"), new Function[] {
new SUM(), new COUNT(), new AVERAGE(), new CHAR(), new DATE(), new MAX(), new MIN(), new TIME(), new RANGE()
});
public static NameAndTypeAndFunctionList[] EMBFUNCTIONS = new NameAndTypeAndFunctionList[] {
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Math_&_Trig"), Function.MATH),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Text"), Function.TEXT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Date_&_Time"), Function.DATETIME),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Logical"), Function.LOGIC),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Array"), Function.ARRAY),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Report"), Function.REPORT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Other"), Function.OTHER),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_Type_Hierarchy"), Function.HA)
};
public static FunctionGroup ALL = new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_All");
}
@Override
public NameAndDescription[] getDescriptions() {
List<NameAndDescription> all = new ArrayList<NameAndDescription>();
for (int i = 0; i < EMBFUNCTIONS.length; i++) {
all.addAll(Arrays.asList(EMBFUNCTIONS[i].getDescriptions()));
}
Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
}
}
java.util.Collections.sort(all, NameAndDescriptionComparator);
return all.toArray(new NameAndDescription[all.size()]);
}
};
private static Comparator<NameAndDescription> NameAndDescriptionComparator = new Comparator<NameAndDescription>() {
@Override
public int compare(NameAndDescription o1, NameAndDescription o2) {
return ComparatorUtils.compare(o1.getName(), o2.getName());
}
};
private static String[] findClassNamesUnderFilePath(String filePath) { private static String[] findClassNamesUnderFilePath(String filePath) {
java.util.List<String> classNameList = new ArrayList<String>(); java.util.List<String> classNameList = new ArrayList<String>();
@ -174,7 +163,7 @@ public abstract class FunctionConstants {
* alex:如果是jar包中的class文件 * alex:如果是jar包中的class文件
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function * file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function
*/ */
if (filePath.indexOf("!/") >= 0) { if (isJarPath(filePath)) {
String[] arr = filePath.split("!/"); String[] arr = filePath.split("!/");
String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符 String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符
String classPath = arr[1]; String classPath = arr[1];
@ -197,7 +186,7 @@ public abstract class FunctionConstants {
} }
String entryName = entry.getName(); String entryName = entry.getName();
if (entryName.indexOf(classPath) < 0 || !entryName.endsWith(".class")) { if (!entryName.contains(classPath) || !entryName.endsWith(".class")) {
continue; continue;
} }
@ -208,57 +197,117 @@ public abstract class FunctionConstants {
} }
} else { } else {
File dir = new File(filePath); File dir = new File(filePath);
File[] files = dir.listFiles();
for (File f : dir.listFiles()) { if (files != null) {
String fileName = f.getName(); for (File f : files) {
if (fileName.endsWith(".class")) { String fileName = f.getName();
classNameList.add(fileName); if (fileName.endsWith(".class")) {
classNameList.add(fileName);
}
} }
} }
} }
return classNameList.toArray(new String[classNameList.size()]); return classNameList.toArray(new String[0]);
} }
// alex:读取com.fr.script.function包下面所有的Function类 private static FunctionGroup getPluginFunctionGroup() {
static { return new FunctionGroup() {
String pkgName = "com.fr.function"; @Override
Class<Function> iface = Function.class; public String getGroupName() {
ClassLoader classloader = iface.getClassLoader(); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Formula_Plugin");
URL url = classloader.getResource(pkgName.replace('.', '/')); }
String classFilePath = url.getFile();
/* @Override
* alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理 public NameAndDescription[] getDescriptions() {
* 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理 FunctionDef[] fs = ExtraClassManager.getInstance().getFunctionDef();
*/ int count = fs.length;
try { FunctionDefNAD[] nads = new FunctionDefNAD[count];
classFilePath = URLDecoder.decode(classFilePath, EncodeConstants.ENCODING_UTF_8); for (int i = 0; i < count; i ++) {
} catch (UnsupportedEncodingException e1) { nads[i] = new FunctionDefNAD(fs[i]);
FRContext.getLogger().error(e1.getMessage(), e1); }
} return nads;
FRContext.getLogger().info("ClassFilePath:" + classFilePath); }
/* };
* alex:如果是jar包中的class文件 }
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function
*/ private static FunctionGroup getCustomFunctionGroup() {
for (String fileName : findClassNamesUnderFilePath(classFilePath)) { return new FunctionGroup() {
try { @Override
Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6)); public String getGroupName() {
if (StableUtils.classInstanceOf(cls, iface)) { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Custom_Function");
Function inst; }
inst = (Function)cls.newInstance();
for (int fi = 0; fi < EMBFUNCTIONS.length; fi++) { @Override
if (EMBFUNCTIONS[fi].test(inst)) { public NameAndDescription[] getDescriptions() {
break; FunctionConfig funtionManager = FunctionConfig.getInstance();
} if (funtionManager != null) {
int functionDefCount = funtionManager.getFunctionDefCount();
FunctionDefNAD[] nads = new FunctionDefNAD[functionDefCount];
for (int i = 0; i < functionDefCount; i++) {
nads[i] = new FunctionDefNAD(funtionManager.getFunctionDef(i));
} }
return nads;
} }
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) { return new NameAndDescription[0];
} catch (IllegalAccessException e) {
} }
} };
}
private static NameAndFunctionList getCommonFunctionList() {
return new NameAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Most_Recently_Used"), new Function[] {
new SUM(), new COUNT(), new AVERAGE(), new CHAR(), new DATE(), new MAX(), new MIN(), new TIME(), new RANGE()
});
}
private static NameAndTypeAndFunctionList[] getEmbededFunctionListArray() {
return new NameAndTypeAndFunctionList[] {
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Math_&_Trig"), Function.MATH),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Text"), Function.TEXT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Date_&_Time"), Function.DATETIME),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Logical"), Function.LOGIC),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Array"), Function.ARRAY),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Report"), Function.REPORT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Other"), Function.OTHER),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_Type_Hierarchy"), Function.HA)
};
}
private static FunctionGroup getAllFunctionGroup() {
return new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_All");
}
@Override
public NameAndDescription[] getDescriptions() {
List<NameAndDescription> all = new ArrayList<NameAndDescription>();
for (int i = 0; i < EMBFUNCTIONS.length; i++) {
all.addAll(Arrays.asList(EMBFUNCTIONS[i].getDescriptions()));
}
Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
}
}
Collections.sort(all, new Comparator<NameAndDescription>() {
@Override
public int compare(NameAndDescription o1, NameAndDescription o2) {
return ComparatorUtils.compare(o1.getName(), o2.getName());
}
});
return all.toArray(new NameAndDescription[0]);
}
};
} }
} }

55
designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java

@ -0,0 +1,55 @@
package com.fr.design.fun;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.stable.fun.mark.Mutable;
import java.util.List;
/**
* 设计器右键菜单接口
*/
public interface RightSelectionHandlerProvider extends Mutable {
int CURRENT_LEVEL = 1;
String XML_TAG = "RightSelectionHandlerProvider";
/**
* 对单元格或者悬浮元素的右键菜单项进行增删改
*
* @param ePane 选择的元素
* @param popupMenu 右键主菜单
*/
void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu);
/**
* 当前实现是否可以作用于当前元素
*
* @param selectableElement 当前选中元素分为CellSelection和FloatSelection(单元格和悬浮元素)
* @return
*/
boolean accept(SelectableElement selectableElement);
/**
* 对表单,参数面板内置的右键选项进行增删改处理
*
* @param actions 默认的action集合 注意:主体代码要求这边的action必须是UndoableAction 的子类而非updateAction
*/
void dmlUpdateActions(BaseFormDesigner formDesigner, List<UpdateAction> actions);
/**
* 当前实现是否可以作用于当前元素
*
* @param formDesigner 当前选中元素分为表单编辑器和参数面板(表单组件元素以及各种控件)
* @return
*/
boolean accept(BaseFormDesigner formDesigner);
}

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

@ -0,0 +1,45 @@
package com.fr.design.fun.impl;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
import java.util.List;
@API(level = RightSelectionHandlerProvider.CURRENT_LEVEL)
public abstract class AbstractRightSelectionHandlerProvider extends AbstractProvider implements RightSelectionHandlerProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public void dmlUpdateActions(BaseFormDesigner formDesigner, List<UpdateAction> actions) {
}
@Override
public boolean accept(BaseFormDesigner formDesigner) {
return false;
}
@Override
public void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu) {
}
@Override
public boolean accept(SelectableElement selectableElement) {
return false;
}
}

16
designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java

@ -667,18 +667,10 @@ public class UIBasicMenuItemUI extends MenuItemUI {
} }
private void installFont(final String prefix, final JComponent menuItem) { private void installFont(final String prefix, final JComponent menuItem) {
Thread thread = new Thread(new Runnable() { if (menuItem == null) {
@Override return;
public void run() { }
if (menuItem == null) { LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font");
return;
}
LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font");
}
});
thread.setName("UIBasicMenuItemUI");
thread.setDaemon(true);
thread.start();
} }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,

14
designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java

@ -1,11 +1,11 @@
package com.fr.design.gui.itextfield; package com.fr.design.gui.itextfield;
import com.fr.design.gui.imenu.UIListPopup; import com.fr.design.gui.imenu.UIListPopup;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import javax.swing.*; import javax.swing.JList;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -13,10 +13,12 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.text.AbstractDocument; import javax.swing.text.AbstractDocument;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Document; import javax.swing.text.Document;
import java.awt.event.ActionEvent;
import java.awt.Dimension; import java.awt.event.ActionListener;
import java.awt.LayoutManager; import java.awt.event.KeyEvent;
import java.awt.event.*; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList; import java.util.ArrayList;
public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener { public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener {

7
designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java

@ -100,10 +100,9 @@ public class CheckBoxTreeCellRenderer extends NullPanel implements TreeCellRende
Border border = treeCellRendererComponent.getBorder(); Border border = treeCellRendererComponent.getBorder();
setBorder(border); setBorder(border);
treeCellRendererComponent.setBorder(BorderFactory.createEmptyBorder()); treeCellRendererComponent.setBorder(BorderFactory.createEmptyBorder());
//todo 可能会发生数组越界,需要处理一下
if (getComponentCount() == 2) { remove((Component) this._actualTreeRenderer);
remove(1);
}
add(treeCellRendererComponent); add(treeCellRendererComponent);
} }

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

@ -69,10 +69,8 @@ public class EnvFileTree extends RefreshableJTree {
if (treeNode.hasFullAuthority()) { if (treeNode.hasFullAuthority()) {
if (lock != null && !node.getUserID().equals(lock)) { if (lock != null && !node.getUserID().equals(lock)) {
name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")"); name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")");
this.setIcon(FileTreeIcon.getIcon(node));
} else {
this.setIcon(FileTreeIcon.getIcon(node, false));
} }
this.setIcon(FileTreeIcon.getIcon(node));
} else { } else {
this.setIcon(FileTreeIcon.getFolderHalfImageIcon()); this.setIcon(FileTreeIcon.getFolderHalfImageIcon());
} }

11
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java

@ -3,6 +3,7 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.icon.LockIcon; import com.fr.design.icon.LockIcon;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -125,8 +126,16 @@ public class FileTreeIcon {
return FOLDER_HALF_IMAGE_ICON; return FOLDER_HALF_IMAGE_ICON;
} }
/**
* 获取文件节点对应的图标
*
* @param node 文件节点
* @return 文件节点的图标
*/
public static Icon getIcon(FileNode node) { public static Icon getIcon(FileNode node) {
return getIcon(node, node.getLock() != null); // 如果文件节点锁不为空且不是当前用户锁定的该模板,那么模板ICON 提示用户当前文件节点被锁
boolean showLock = node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock());
return getIcon(node, showLock);
} }
public static Icon getIcon(FileNode node, boolean isShowLock) { public static Icon getIcon(FileNode node, boolean isShowLock) {

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

@ -1,16 +1,16 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import javax.swing.JComponent;
import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseContainerProvider;
import javax.swing.JComponent;
/** /**
* Author : Shockway * Author : Shockway
* Date: 13-7-15 * Date: 13-7-15
* Time: 上午10:28 * Time: 上午10:28
*/ */
public interface BaseJForm extends JTemplateProvider { public interface BaseJForm<T> extends JTemplateProvider<T> {
String XML_TAG = "JForm"; String XML_TAG = "JForm";
int FORM_TAB = 0; int FORM_TAB = 0;
@ -32,11 +32,6 @@ public interface BaseJForm extends JTemplateProvider {
*/ */
void refreshSelectedWidget(); void refreshSelectedWidget();
/**
* 获取当前的Target
*/
Object getTarget();
/** /**
* 执行撤销 * 执行撤销
* *

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

@ -10,6 +10,7 @@ import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
@ -17,6 +18,7 @@ import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane; import com.fr.design.file.NewTemplatePane;
@ -29,13 +31,13 @@ import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuManager; import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exception.DecryptTemplateException; import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE; import com.fr.file.FILE;
@ -66,6 +68,7 @@ import javax.swing.JLayeredPane;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
@ -76,7 +79,6 @@ import java.awt.Graphics;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
@ -160,9 +162,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//用于判断设计器是否打开了 //用于判断设计器是否打开了
private boolean designerOpened = false; private boolean designerOpened = false;
private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()); private int contentWidth = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()); private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight());
private WindowAdapter windowAdapter = new WindowAdapter() { private WindowAdapter windowAdapter = new WindowAdapter() {
@ -224,16 +226,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
DesignerMode.setMode(DesignerMode.NORMAL); closeAuthorityEditing();
WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
DesignerContext.getDesignerFrame().resetToolkitByPlus(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus());
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
} }
} }
@ -332,6 +326,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.progressDialog = new ProgressDialog(this); this.progressDialog = new ProgressDialog(this);
} }
public void closeAuthorityEditing(){
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
DesignerContext.getDesignerFrame().resetToolkitByPlus(
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus());
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
}
/** /**
* 注册app. * 注册app.
* *
@ -407,7 +413,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void on(PluginEvent event) { public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad); refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame(); SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (DesignerContext.getDesignerFrame() == null) {
return;
}
DesignerContext.getDesignerFrame().refresh();
DesignerContext.getDesignerFrame().repaint();
}
});
} }
}, new PluginFilter() { }, new PluginFilter() {
@ -809,14 +824,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 报表运行环境改变时,需要刷新某些面板 * 报表运行环境改变时,需要刷新某些面板
*/ */
public void refreshEnv() { public void refreshEnv() {
refresh();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TemplateTreePane.getInstance().refreshDockingView();
}
/**
* 安装设计器相关插件时的刷新
*/
public void refresh() {
this.setTitle(); this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView();
DesignTableDataManager.clearGlobalDs(); DesignTableDataManager.clearGlobalDs();
EastRegionContainerPane.getInstance().refreshDownPane(); EastRegionContainerPane.getInstance().refreshDownPane();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
template.refreshToolArea(); template.refreshToolArea();
@ -849,18 +869,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing(); editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName())); editingTemplate.getEditingFILE().getName()));
} }
} else { } else {
if (editingTemplate.saveTemplate()) { if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName())); editingTemplate.getEditingFILE().getName()));
} }
} }
@ -957,8 +977,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// p:判断一下,如何文件为空或者文件不存在,直接返回. // p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) { if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), JOptionPane.showMessageDialog(
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); this,
Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME,
JOptionPane.INFORMATION_MESSAGE
);
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
return; return;
} }
@ -968,7 +992,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} catch (DecryptTemplateException e) { } catch (DecryptTemplateException e) {
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
this, this,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"), Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
UIManager.getString("OptionPane.messageDialogTitle"), UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.WARNING_MESSAGE, JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon") UIManager.getIcon("OptionPane.errorIcon")
@ -1027,7 +1051,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
MutilTempalteTabPane.getInstance().setTemTemplate( MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
} else { } else {
activeTemplate(tplFile, jt); activeTemplate(jt);
} }
opened = true; opened = true;
break; break;
@ -1042,13 +1066,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 激活指定的模板 * 激活指定的模板
* *
* @param tplFile 模板文件 * @param jt 当前报表
* @param jt 当前报表
* @date 2014-10-14-下午6:31:23 * @date 2014-10-14-下午6:31:23
*/ */
private void activeTemplate(FILE tplFile, JTemplate jt) { private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListPane.getInstance().contains(tplFile.getPath()); int index = HistoryTemplateListPane.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
if (index != -1) { if (index != -1) {
historyList.get(index).activeJTemplate(index, jt); historyList.get(index).activeJTemplate(index, jt);

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

@ -30,11 +30,18 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
@ -68,6 +75,22 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
static {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
DesignUtils.refreshDesignerFrame();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign, ShortCut.TEMPLATE_TREE);
}
});
}
private static final String FILE = "file"; private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS; private static volatile DesignerFrameFileDealerPane THIS;
@ -163,7 +186,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新菜单 * 刷新菜单
*/ */
public void refreshDockingView() { public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(newFolderAction, refreshTreeAction); toolbarDef.addShortCut(newFolderAction, refreshTreeAction);
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
@ -406,8 +428,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String oldName = fnf.getName(); String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY); oldName = oldName.replace(suffix, StringUtils.EMPTY);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setModal(true); this.setModal(true);

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

@ -412,6 +412,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
if (propertyItem.isVisible() && propertyItem.isEnabled() && !propertyItem.isPoppedOut()) { if (propertyItem.isVisible() && propertyItem.isEnabled() && !propertyItem.isPoppedOut()) {
propertyCard.show(rightPane, tabName); propertyCard.show(rightPane, tabName);
propertyItem.setTabButtonSelected(); propertyItem.setTabButtonSelected();
//从单元格菜单过来也要关闭弹出窗
hideCurrentPopupPane();
} }
} }

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

@ -32,6 +32,7 @@ import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
@ -56,6 +57,8 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID; import com.fr.stable.core.UUID;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
@ -72,7 +75,7 @@ import java.util.regex.Pattern;
/** /**
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件) * 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/ */
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, JTemplateProvider, DesignerProxy { public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000; private static final int PREFIX_NUM = 3000;
private FILE editingFILE = null; private FILE editingFILE = null;
@ -419,7 +422,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
fireSuperTargetModified(); fireSuperTargetModified();
} }
protected boolean accept(Object o) { public boolean accept(Object o) {
return true; return true;
} }
@ -519,19 +522,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (editingFILE == null) { if (editingFILE == null) {
return false; return false;
} }
// //检查一下连接是否成功
// try {
// if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
// //连接不成功,提示
// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
// com.fr.design.i18n.Toolkit.i18nText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"})
// , com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE);
// return false;
// }
// } catch (Exception e) {
// FineLoggerFactory.getLogger().error(e.getMessage(), e);
// }
// 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs
if (!editingFILE.exists()) { if (!editingFILE.exists()) {
@ -587,6 +577,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (isCancelOperation(chooseResult)) { if (isCancelOperation(chooseResult)) {
return false; return false;
} }
// 源文件
FILE sourceFile = editingFILE;
if (isOkOperation(chooseResult)) { if (isOkOperation(chooseResult)) {
boolean access = false; boolean access = false;
@ -596,13 +588,33 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (!access) { if (!access) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false; return false;
} }
// 目标文件
editingFILE = fileChooser.getSelectedFILE(); editingFILE = fileChooser.getSelectedFILE();
} }
return saveNewFile(editingFILE, oldName); boolean lockedTarget = WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath());
if (lockedTarget) {
boolean saved = saveNewFile(editingFILE, oldName);
// 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉
if (saved && !ComparatorUtils.equals(editingFILE.getPath(), sourceFile.getPath())) {
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(sourceFile.getPath());
}
return saved;
} else {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false;
}
} }
protected boolean saveNewFile(FILE editingFILE, String oldName) { protected boolean saveNewFile(FILE editingFILE, String oldName) {

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

@ -1,6 +1,8 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
public interface JTemplateProvider { public interface JTemplateProvider<T> {
public void fireTargetModified(); void fireTargetModified();
T getTarget();
} }

9
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java

@ -30,6 +30,8 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
private int patternIndex = 0; // pattern setIndex. private int patternIndex = 0; // pattern setIndex.
private final static int DEFAULT_DIM_HEIGHT = 210; private final static int DEFAULT_DIM_HEIGHT = 210;
private final static Color DEFAULT_FOREGROUND = Color.lightGray;
private final static Color DEFAULT_BACKGROUND = Color.black;
private ColorSelectBox foregroundColorPane; private ColorSelectBox foregroundColorPane;
private ColorSelectBox backgroundColorPane; private ColorSelectBox backgroundColorPane;
private PatternButton[] patternButtonArray; private PatternButton[] patternButtonArray;
@ -52,7 +54,8 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
} }
foregroundColorPane = new ColorSelectBox(60); foregroundColorPane = new ColorSelectBox(60);
backgroundColorPane = new ColorSelectBox(60); backgroundColorPane = new ColorSelectBox(60);
foregroundColorPane.setSelectObject(DEFAULT_FOREGROUND);
foregroundColorPane.setSelectObject(DEFAULT_BACKGROUND);
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
@ -219,7 +222,7 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override @Override
public void reset() { public void reset() {
patternButtonArray[0].setSelected(true); patternButtonArray[0].setSelected(true);
foregroundColorPane.setSelectObject(null); foregroundColorPane.setSelectObject(DEFAULT_FOREGROUND);
backgroundColorPane.setSelectObject(null); backgroundColorPane.setSelectObject(DEFAULT_BACKGROUND);
} }
} }

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

@ -68,4 +68,14 @@ public class LogMessageBar extends JPanel {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(width, 24); return new Dimension(width, 24);
} }
/**
* 销毁内置的日志面板,外部插件会用到
*/
public void disposeLogDialog() {
if (dlg != null && dlg.isShowing()) {
dlg.dispose();
}
THIS = null;
}
} }

25
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java

@ -7,11 +7,15 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle; import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyle; import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane { public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane {
@ -40,17 +44,17 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
@Override @Override
public MobileTemplateStyle updateBean() { public MobileTemplateStyle updateBean() {
return new DefaultMobileTemplateStyle(); return getDefaultTemplateStyle();
} }
public MobileTemplateStyle updateConfig(){ public MobileTemplateStyle updateConfig(){
return new DefaultMobileTemplateStyle(); return getDefaultTemplateStyle();
} }
@Override @Override
protected MobileTemplateStyle getDefaultTemplateStyle() { protected MobileTemplateStyle getDefaultTemplateStyle() {
return new DefaultMobileTemplateStyle(); return new DefaultMobileTemplateStyle(new TabFontConfig(getTagLayout().getTitleFont()));
} }
@Override @Override
@ -73,6 +77,10 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
this.setBackground(DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR); this.setBackground(DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR);
} }
public Color getInitialColor() {
return DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR;
}
public void repaint() { public void repaint() {
super.repaint(); super.repaint();
} }
@ -84,7 +92,8 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
int panelWidth = dimension.width; int panelWidth = dimension.width;
int panelHeight = dimension.height; int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
FRFont frFont = DefaultMobileTemplateStyle.DEFAULT_TAB_FONT.getFont(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont); FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = DefaultMobileStyleDefinePane.this.getTagLayout(); WCardTagLayout cardTagLayout = DefaultMobileStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount(); int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
@ -92,11 +101,13 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
int fontHeight = fm.getHeight(); int fontHeight = fm.getHeight();
int ascentHeight = fm.getAscent(); int ascentHeight = fm.getAscent();
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
if (i == 0) { if (i == 0) {
g2d.setColor(Color.BLACK);
g2d.setStroke(new BasicStroke(2.0f)); g2d.setStroke(new BasicStroke(2.0f));
g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1); g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1);
} }

8
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java

@ -27,6 +27,7 @@ import java.awt.FlowLayout;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke; import java.awt.Stroke;
import java.util.ArrayList; import java.util.ArrayList;
@ -151,6 +152,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
int panelWidth = dimension.width; int panelWidth = dimension.width;
int panelHeight = dimension.height; int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont(); FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont); FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = DownMenuStyleDefinePane.this.getTagLayout(); WCardTagLayout cardTagLayout = DownMenuStyleDefinePane.this.getTagLayout();
@ -161,8 +163,8 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
if(i == 0){ if(i == 0){
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor()); g2d.setColor(this.getSelectColor());
@ -171,7 +173,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
} }
Icon icon = new Icon(PAINT_ICON, ICON_PATH); Icon icon = new Icon(PAINT_ICON, ICON_PATH);
g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null); g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent);
Stroke oldStroke = g2d.getStroke(); Stroke oldStroke = g2d.getStroke();
if (splitLine.getLineStyle() != 0) { if (splitLine.getLineStyle() != 0) {
g2d.setColor(splitLine.getColor()); g2d.setColor(splitLine.getColor());

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

@ -208,8 +208,10 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
MobileTemplateStyle ob = updateSubStyle(); MobileTemplateStyle ob = updateSubStyle();
ob.setCustom(custom.getSelectedIndex() == 1); ob.setCustom(custom.getSelectedIndex() == 1);
ob.setInitialColor(initialColorBox.getSelectObject()); ob.setInitialColor(initialColorBox.getSelectObject());
TabFontConfig config = ob.getTabFontConfig(); TabFontConfig config = new TabFontConfig();
config.setSelectColor(ob.getTabFontConfig().getSelectColor());
config.setFont(fontConfPane.update()); config.setFont(fontConfPane.update());
ob.setTabFontConfig(config);
return ob; return ob;
} }

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

@ -24,6 +24,7 @@ import java.awt.FlowLayout;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane { public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane {
private NewColorSelectBox initDotColor; private NewColorSelectBox initDotColor;
@ -131,6 +132,7 @@ public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane {
Dimension dimension = this.getSize(); Dimension dimension = this.getSize();
int panelHeight = dimension.height; int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont(); FRFont frFont = this.getTabFontConfig().getFont();
g2d.setFont(frFont); g2d.setFont(frFont);
g2d.setColor(frFont.getForeground()); g2d.setColor(frFont.getForeground());

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

@ -10,6 +10,7 @@ import com.fr.design.mainframe.widget.MobileTabFontConfPane;
import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle; import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
@ -97,7 +98,10 @@ public abstract class StyleDefinePaneWithSelectConf extends MobileTemplateStyleD
public MobileTemplateStyle updateSubStyle() { public MobileTemplateStyle updateSubStyle() {
MobileTemplateStyle mobileTemplateStyle = updateStyleWithSelectConf(); MobileTemplateStyle mobileTemplateStyle = updateStyleWithSelectConf();
mobileTemplateStyle.setSelectColor(selectColorBox.getSelectObject()); mobileTemplateStyle.setSelectColor(selectColorBox.getSelectObject());
mobileTemplateStyle.getTabFontConfig().setSelectColor(selectFontColor.getColor()); TabFontConfig config = new TabFontConfig();
config.setFont(mobileTemplateStyle.getTabFontConfig().getFont());
config.setSelectColor(selectFontColor.getColor());
mobileTemplateStyle.setTabFontConfig(config);
return mobileTemplateStyle; return mobileTemplateStyle;
} }

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

@ -24,9 +24,10 @@ public class TemplateStyleDefinePaneFactory {
public static BasicBeanPane<MobileTemplateStyle> createDefinePane(String style, WCardTagLayout tagLayout) { public static BasicBeanPane<MobileTemplateStyle> createDefinePane(String style, WCardTagLayout tagLayout) {
StyleDefinePaneUI styleDefinePaneUI = defineMap.get(style); StyleDefinePaneUI styleDefinePaneUI = defineMap.get(style);
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = styleDefinePaneUI.getaClass(); if(styleDefinePaneUI == null){
if (clazz == null) { styleDefinePaneUI = defineMap.get(DefaultMobileTemplateStyle.STYLE_NAME);
} }
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = styleDefinePaneUI.getaClass();
BasicBeanPane<MobileTemplateStyle> quickPane = null; BasicBeanPane<MobileTemplateStyle> quickPane = null;
try { try {
quickPane = Reflect.on(clazz).create(tagLayout).get(); quickPane = Reflect.on(clazz).create(tagLayout).get();

10
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java

@ -27,6 +27,7 @@ import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke; import java.awt.Stroke;
public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
@ -171,7 +172,8 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
int panelWidth = dimension.width; int panelWidth = dimension.width;
int panelHeight = dimension.height; int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
FRFont frFont = UpMenuStyleDefinePane.this.fontConfPane.update(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont); FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = UpMenuStyleDefinePane.this.getTagLayout(); WCardTagLayout cardTagLayout = UpMenuStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount(); int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
@ -186,15 +188,15 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
if(i == 0){ if(i == 0){
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor()); g2d.setColor(this.getSelectColor());
g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2); g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2);
g2d.setColor(oldColor); g2d.setColor(oldColor);
} }
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
Stroke oldStroke = g2d.getStroke(); Stroke oldStroke = g2d.getStroke();
if (i == 0) { if (i == 0) {
g2d.setColor(this.underLine.getColor()); g2d.setColor(this.underLine.getColor());

21
designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java

@ -5,6 +5,7 @@ import com.fr.general.cardtag.mobile.TabFontConfig;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color; import java.awt.Color;
import java.awt.FontMetrics;
public abstract class MobileTemplatePreviewPane extends JPanel { public abstract class MobileTemplatePreviewPane extends JPanel {
private Color initialColor; private Color initialColor;
@ -35,18 +36,32 @@ public abstract class MobileTemplatePreviewPane extends JPanel {
this.tabFontConfig = tabFontConfig; this.tabFontConfig = tabFontConfig;
} }
public MobileTemplatePreviewPane(){ public MobileTemplatePreviewPane() {
} }
public void populateConfig(MobileTemplateStyle templateStyle){ public void populateConfig(MobileTemplateStyle templateStyle) {
this.setInitialColor(templateStyle.getInitialColor()); this.setInitialColor(templateStyle.getInitialColor());
this.setBackground(templateStyle.getInitialColor()); this.setBackground(templateStyle.getInitialColor());
this.setSelectColor(templateStyle.getSelectColor()); this.setSelectColor(templateStyle.getSelectColor());
this.setTabFontConfig(templateStyle.getTabFontConfig()); this.setTabFontConfig(templateStyle.getTabFontConfig());
} }
public void repaint (){ protected String calculateDisplayName(String widgetName, FontMetrics fm, int eachWidth) {
StringBuffer buffer = new StringBuffer();
String result;
for (int i = 0; i < widgetName.length(); i++) {
result = buffer.toString();
buffer.append(widgetName.charAt(i));
if (fm.stringWidth(buffer.toString()) > eachWidth) {
return result;
}
}
return buffer.toString();
}
public void repaint() {
super.repaint(); super.repaint();
} }

21
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -8,11 +8,16 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import javax.swing.BorderFactory;
import javax.swing.*; import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -92,11 +97,15 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
centerPane.add(Box.createVerticalStrut(1)); centerPane.add(Box.createVerticalStrut(1));
// mod by anchore 16/11/16 // mod by anchore 16/11/16
UIButton customButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_More_Color")); final UIButton customButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_More_Color"));
customButton.addActionListener(new ActionListener() { // 不能使用 ActionListener,否则设计器工具栏中的"更多颜色"按钮会有问题(REPORT-13654)
customButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void mousePressed(MouseEvent e) {
if (!customButton.isEnabled()) {
return;
}
customButtonPressed(); customButtonPressed();
} }
}); });

24
designer-base/src/main/java/com/fr/design/style/color/PickColorButtonFactory.java

@ -4,11 +4,15 @@ import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.SpecialUIButton; import com.fr.design.gui.ibutton.SpecialUIButton;
import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.design.gui.ibutton.UIBasicButtonUI;
import javax.swing.*; import javax.swing.JButton;
import javax.swing.plaf.ButtonUI; import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicButtonUI; import java.awt.Color;
import java.awt.*; import java.awt.Cursor;
import java.awt.event.*; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/** /**
* Created by plough on 2016/12/22. * Created by plough on 2016/12/22.
@ -28,7 +32,7 @@ class PickColorButtonFactory {
* @return SpecialUIButton 屏幕取色按钮 * @return SpecialUIButton 屏幕取色按钮
*/ */
static JButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final boolean setColorRealTime) { static JButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final boolean setColorRealTime) {
SpecialUIButton pickColorButton = new SpecialUIButton(new WhiteButtonUI()); final SpecialUIButton pickColorButton = new SpecialUIButton(new WhiteButtonUI());
PickColorButtonFactory.iconType = iconType; PickColorButtonFactory.iconType = iconType;
if (iconType == IconType.ICON16) { if (iconType == IconType.ICON16) {
@ -42,9 +46,13 @@ class PickColorButtonFactory {
pickColorButton.setPreferredSize(new Dimension(iconSize, iconSize)); pickColorButton.setPreferredSize(new Dimension(iconSize, iconSize));
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
pickColorButton.addActionListener(new ActionListener() { // 不能使用 ActionListener,否则设计器工具栏中的取色按钮会有问题(REPORT-13654)
pickColorButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void mousePressed(MouseEvent e) {
if (!pickColorButton.isEnabled()) {
return;
}
new ColorPicker(colorSelectable, setColorRealTime); new ColorPicker(colorSelectable, setColorRealTime);
} }
}); });

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

@ -65,12 +65,12 @@ public class DesignUtils {
* @return 启动了返回true * @return 启动了返回true
*/ */
public static boolean isStarted() { public static boolean isStarted() {
// try { try {
// new Socket("localhost", port); new Socket("localhost", port);
// return true; return true;
// } catch (Exception exp) { } catch (Exception exp) {
//
// } }
return false; return false;
} }

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

@ -511,14 +511,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
} }
private void tryConnectRemoteEnv() { private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() { final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override @Override
protected Boolean doInBackground() throws Exception { protected Boolean doInBackground() throws Exception {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkspaceConnectionInfo connection = remoteEnv.getConnection();
DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath()); DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath());
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try { try {
@ -532,18 +532,26 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
protected void done() { protected void done() {
okButton.setEnabled(true); okButton.setEnabled(true);
try { try {
Boolean result = get();
if (result == null) { TestConnectionResult result = TestConnectionResult.parse(get(), connection);
if (result == TestConnectionResult.Fully_Success) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
}
if (result == TestConnectionResult.Partly_Sucess) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistence_Test"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
}
if (result == TestConnectionResult.Fully_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
}
if (result == TestConnectionResult.Auth_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} else {
if (result) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
} else {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
}
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
@ -589,7 +597,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true); dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true);
dialog.setSize(new Dimension(268, 118)); dialog.setSize(new Dimension(308, 132));
okButton.setEnabled(false); okButton.setEnabled(false);
JPanel jp = new JPanel(); JPanel jp = new JPanel();
JPanel upPane = new JPanel(); JPanel upPane = new JPanel();

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

@ -0,0 +1,62 @@
package com.fr.env;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
/**
* 测试连接的结果
* 不改变原有逻辑的情况下加入一层转化
* 根据这里的转化结果判断需要提示哪些内容
*
* created by Harrison on 2018/12/20
**/
public enum TestConnectionResult {
/**
* 完全成功, 版本匹配测试连接成功
*/
Fully_Success,
/**
* 不完全成功版本不匹配但测试连接成功
*/
Partly_Sucess,
/**
* 完全失败直接没连上
*/
Fully_Failed,
/**
* 验证 Token 失败
*/
Auth_Failed;
public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) {
if (value == null) {
return Auth_Failed;
}
if (!value) {
return Fully_Failed;
}
try {
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return Fully_Success;
}
return Partly_Sucess;
} catch (Exception e) {
// 发生异常,说明没连接上。返回完全失败。
FineLoggerFactory.getLogger().error(e.getMessage());
return Fully_Failed;
}
}
}

2
designer-base/src/main/resources/com/fr/design/insert/formula/variable/cn/servletURL.txt

@ -1 +1 @@
假如访问:http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,servletURL指的是:/WebReport/ReportServer 假如访问的是http://localhost:8075/webroot/decision/view/report?viewlet=workbook1.cpt,servletURL指的是:/webroot/decision/view/report

2
designer-base/src/main/resources/com/fr/design/insert/formula/variable/en/servletURL.txt

@ -1 +1 @@
http://localhost:8080/WebReport/ReportServer?reportlet=WorkBook1.cpt,servletURL is /WebReport/ReportServer http://localhost:8075/webroot/decision/view/report?viewlet=workbook1.cpt,servletURL is /webroot/decision/view/report

76
designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java

@ -0,0 +1,76 @@
package com.fr.design.formula;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static junit.framework.Assert.fail;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
/**
* Created by plough on 2018/12/7.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(GeneralUtils.class)
public class FunctionConstantsTest {
@Test
public void testNewInstanceFail() throws Exception {
try {
FunctionConstants.class.newInstance();
fail("Not allowed to instantiate FunctionConstants!");
} catch (IllegalAccessException e) {
assertTrue(true);
}
}
@Test
public void testEmbedFuntionsAfterStaticInit() {
NameAndTypeAndFunctionList[] embFunctionLists = FunctionConstants.EMBFUNCTIONS;
// 一共有 8 个分类
assertEquals(8, embFunctionLists.length);
for (NameAndTypeAndFunctionList embFunctionsList : embFunctionLists) {
// 每个分类下都有函数
NameAndDescription[] nameAndDescriptions = embFunctionsList.getDescriptions();
assertTrue(nameAndDescriptions.length > 0);
}
}
@Test
public void testCommonFuntionsAfterStaticInit() {
NameAndFunctionList commonFunctionList = FunctionConstants.COMMON;
assertEquals(9, commonFunctionList.getDescriptions().length);
}
@Test
public void testIsCustomFormulaPathRunWithCode() {
PowerMock.mockStatic(GeneralUtils.class);
EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes();
PowerMock.replayAll();
String classFilePath = "/Users/plough/.m2/repository/com/fr/core/fine-core/10.0-RELEASE-SNAPSHOT/fine-core-10.0-RELEASE-20181211.024527-499.jar!/com/fr/function";
assertFalse(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).<Boolean>get());
classFilePath = "/Users/plough/work/new_10_release_finereport/engine-settings/env/webroot/WEB-INF/classes/com/fr/function";
assertFalse(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).<Boolean>get());
}
@Test
public void testIsCustomFormulaPathRunWithJar() {
PowerMock.mockStatic(GeneralUtils.class);
EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("Build#release-2018.12.10.12.11.09.95").anyTimes();
PowerMock.replayAll();
String classFilePath = "file:/Applications/FineReport_10.0_12_10/webapps/webroot/WEB-INF/lib/fine-report-engine-10.0.jar!/com/fr/function";
assertFalse(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).<Boolean>get());
classFilePath = "/Applications/FineReport_10.0_12_10/webapps/webroot/WEB-INF/classes/com/fr/function";
assertTrue(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).<Boolean>get());
}
}

8
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkNorthPane.java

@ -110,12 +110,14 @@ public class FormHyperlinkNorthPane extends BasicBeanPane<FormHyperlinkProvider>
} }
String editorName = formHyperlink.getRelateEditorName(); String editorName = formHyperlink.getRelateEditorName();
//防止初始的时候有空白选项 //防止初始的时候有空白选项
if (editorName == null) { String[] formHyperlinkEditNames = getFormHyperlinkEditNames();
return; if (editorName == null && formHyperlinkEditNames.length > 0) {
editorName = formHyperlinkEditNames[0];
formHyperlink.setRelateEditorName(editorName);
} }
if (targetFrameComboBox != null) { if (targetFrameComboBox != null) {
//noinspection unchecked //noinspection unchecked
targetFrameComboBox.setModel(new DefaultComboBoxModel(getFormHyperlinkEditNames())); targetFrameComboBox.setModel(new DefaultComboBoxModel(formHyperlinkEditNames));
targetFrameComboBox.setSelectedItem(editorName); targetFrameComboBox.setSelectedItem(editorName);
} }
} }

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartDatapointLabelPane.java

@ -96,7 +96,7 @@ public class ChartDatapointLabelPane extends BasicPane{
boolean isGuidline = plot.isSupportLeadLine(); boolean isGuidline = plot.isSupportLeadLine();
if(plot.isSupportCategoryFilter()) { if(plot.isSupportCategoryFilter()) {
isCategory = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name")); isCategory = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"));
} }
isSeries = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name")); isSeries = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"));
isValue = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value")); isValue = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"));

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/CustomDefaultSeriesPane.java

@ -240,7 +240,7 @@ public class CustomDefaultSeriesPane extends BasicPane{
isCurve = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve_Smooth")); isCurve = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve_Smooth"));
lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
markerPane = new MarkerComboBox(MarkerFactory.getMarkerArray()); markerPane = new MarkerComboBox(MarkerFactory.getMarkerArray());
String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")}; String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")};
Boolean[] valueArray = {true, false}; Boolean[] valueArray = {true, false};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray); isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/CustomTypeConditionSeriesPane.java

@ -449,7 +449,7 @@ public class CustomTypeConditionSeriesPane extends BasicBeanPane<CustomAttr>{
lineStyle.setPreferredSize(new Dimension(150,20)); lineStyle.setPreferredSize(new Dimension(150,20));
markerPane.setPreferredSize(new Dimension(150,20)); markerPane.setPreferredSize(new Dimension(150,20));
String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")}; String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")};
Boolean[] valueArray = {true, false}; Boolean[] valueArray = {true, false};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray); isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/LineSeriesPane.java

@ -49,7 +49,7 @@ public class LineSeriesPane extends AbstractPlotSeriesPane{
isCurve = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve_Smooth")); isCurve = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve_Smooth"));
lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
markerPane = new MarkerComboBox(MarkerFactory.getMarkerArray()); markerPane = new MarkerComboBox(MarkerFactory.getMarkerArray());
String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")}; String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")};
Boolean[] valueArray = {true, false}; Boolean[] valueArray = {true, false};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray); isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/RadarSeriesPane.java

@ -45,7 +45,7 @@ public class RadarSeriesPane extends AbstractPlotSeriesPane{
isCurve = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill")); isCurve = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill"));
lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
markerPane = new MarkerComboBox(MarkerFactory.getMarkerArray()); markerPane = new MarkerComboBox(MarkerFactory.getMarkerArray());
String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")}; String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Break"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Continue")};
Boolean[] valueArray = {true, false}; Boolean[] valueArray = {true, false};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray); isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);

5
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -13,6 +13,7 @@ import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -49,7 +50,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
JPanel northPane = new JPanel(new BorderLayout()); JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER); northPane.add(jcb, BorderLayout.CENTER);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"));
label.setPreferredSize(new Dimension(82, 20)); label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20));
northPane.add(label, BorderLayout.WEST); northPane.add(label, BorderLayout.WEST);
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER); this.add(cardPane, BorderLayout.CENTER);
@ -134,7 +135,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
}; };
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double[] columnSize = {76, 120}; double[] columnSize = {78, 122};
double[] rowSize = {p, p, p}; double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);

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

@ -4,6 +4,7 @@ import com.fr.chart.base.ChartConstants;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -28,7 +29,7 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
double[] columnSize = {f, e}; double[] columnSize = {f, e};
double[] rowSize = {p}; double[] rowSize = {p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style")), styleBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style")), styleBox},
} ; } ;
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
@ -36,8 +37,8 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
} }
protected String[] getNameArray(){ protected String[] getNameArray(){
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Name"), return new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Name"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Top_Down_Shade") Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade")
}; };
} }
@Override @Override

4
designer-chart/src/main/java/com/fr/van/chart/designer/component/format/CategoryNameFormatPaneWithCheckBox.java

@ -1,6 +1,7 @@
package com.fr.van.chart.designer.component.format; package com.fr.van.chart.designer.component.format;
import com.fr.design.i18n.Toolkit;
import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -18,6 +19,7 @@ public class CategoryNameFormatPaneWithCheckBox extends VanChartFormatPaneWithCh
@Override @Override
protected String getCheckBoxText() { protected String getCheckBoxText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"); //"分类名" 图表(新特性)标签、提示时有用到
return Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name");
} }
} }

11
designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java

@ -4,8 +4,9 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.plugin.chart.map.server.GEOJSONHelper; import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JTree; import javax.swing.JTree;
@ -78,7 +79,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent(); DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent();
return GEOJSONHelper.getInstance().getJsonUrlByPath(currentSel.getUserObject().toString()); return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString());
} }
//根据路径精确查找 //根据路径精确查找
@ -96,7 +97,7 @@ public class MapDataTree extends JTree {
return null; return null;
} }
String dirPath = el.getUserObject().toString(); String dirPath = el.getUserObject().toString();
String url = GEOJSONHelper.getInstance().getJsonUrlByPath(dirPath); String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath);
if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){ if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){
selectTreeNode(el, m_model); selectTreeNode(el, m_model);
return el; return el;
@ -133,7 +134,7 @@ public class MapDataTree extends JTree {
if(treeNode == null || treeNode.getUserObject() == null){ if(treeNode == null || treeNode.getUserObject() == null){
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
return GEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString()); return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString());
} }
//模糊搜索 深度优先. //模糊搜索 深度优先.
@ -149,7 +150,7 @@ public class MapDataTree extends JTree {
DefaultMutableTreeNode el = els.nextElement(); DefaultMutableTreeNode el = els.nextElement();
String path = el.getUserObject().toString(); String path = el.getUserObject().toString();
String fileName = GEOJSONHelper.getPresentNameWithPath(path); String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path);
if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) { if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) {
selectTreeNode(el, m_model); selectTreeNode(el, m_model);
return; return;

2
designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java

@ -44,7 +44,7 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane {
//设置色彩面板内容 //设置色彩面板内容
protected void setColorPaneContent (JPanel panel) { protected void setColorPaneContent (JPanel panel) {
if (stylePane != null) { if (stylePane != null) {
panel.add(createStylePane(), BorderLayout.CENTER); panel.add(stylePane, BorderLayout.CENTER);
} }
panel.add(createAlphaPane(), BorderLayout.SOUTH); panel.add(createAlphaPane(), BorderLayout.SOUTH);
} }

10
designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java

@ -18,15 +18,15 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.plugin.chart.base.GisLayer; import com.fr.plugin.chart.base.GisLayer;
import com.fr.plugin.chart.base.ViewCenter; import com.fr.plugin.chart.base.ViewCenter;
import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper;
import com.fr.plugin.chart.map.layer.WMSLayer; import com.fr.plugin.chart.map.layer.WMSLayer;
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper;
import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper;
import com.fr.plugin.chart.map.server.GEOJSONHelper; import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.plugin.chart.map.server.MapLayerConfigManager; import com.fr.plugin.chart.map.server.MapLayerConfigManager;
import com.fr.plugin.chart.service.WMSFactory; import com.fr.plugin.chart.service.WMSFactory;
import com.fr.plugin.chart.type.GISLayerType; import com.fr.plugin.chart.type.GISLayerType;
@ -201,7 +201,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
} else if(o instanceof String){//list里面没有 } else if(o instanceof String){//list里面没有
selectTreePath = null; selectTreePath = null;
this.tree.setSelectionPath(null); this.tree.setSelectionPath(null);
this.getModel().setSelectedItem(GEOJSONHelper.getPresentNameWithPath((String) o)); this.getModel().setSelectedItem(ChartGEOJSONHelper.getPresentNameWithPath((String) o));
} }
} }
@ -209,7 +209,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
protected String pathToString(TreePath path) { protected String pathToString(TreePath path) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
//不显示后缀 //不显示后缀
return GEOJSONHelper.getPresentNameWithPath(node.toString()); return ChartGEOJSONHelper.getPresentNameWithPath(node.toString());
} }
@Override @Override
@ -533,7 +533,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams()); GEOJSONTreeHelper.getInstance().updateParamRootNode(VanChartMapSourceChoosePane.this.getParams());
if(selectTreePath != null){ if(selectTreePath != null){
mapDataTree.setSelectNodePath(GEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString())); mapDataTree.setSelectNodePath(CompatibleGEOJSONHelper.completeJSONName(selectTreePath.getLastPathComponent().toString()));
selectTreePath = mapDataTree.getSelectionPath(); selectTreePath = mapDataTree.getSelectionPath();
} }

16
designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java

@ -3,11 +3,15 @@ package com.fr.design.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark; import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark;
import com.fr.design.actions.JTemplateAction; import com.fr.design.actions.JTemplateAction;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.form.mobile.FormMobileAttrPane; import com.fr.design.form.mobile.FormMobileAttrPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
@ -73,6 +77,9 @@ public class FormMobileAttrAction extends JTemplateAction<JForm> {
formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后 formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后
((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified();
jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent()); jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent());
//改变布局为自适应布局,只在移动端属性设置保存后改变一次
doChangeBodyLayout();
WidgetPropertyPane.getInstance().refreshDockingView(); WidgetPropertyPane.getInstance().refreshDockingView();
jf.fireTargetModified(); jf.fireTargetModified();
} }
@ -80,6 +87,15 @@ public class FormMobileAttrAction extends JTemplateAction<JForm> {
dialog.setVisible(true); dialog.setVisible(true);
} }
private void doChangeBodyLayout(){
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer rootLayout = formDesigner.getRootComponent();
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) {
rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0);
}
((XWFitLayout)formDesigner.getRootComponent()).switch2FitBodyLayout(rootLayout);
}
@Focus(id = "com.fr.mobile.mobile_template_frm", text = "Fine-Design_Function_Mobile_Template_Frm", source = Original.EMBED) @Focus(id = "com.fr.mobile.mobile_template_frm", text = "Fine-Design_Function_Mobile_Template_Frm", source = Original.EMBED)
private void recordFunction() { private void recordFunction() {
// do nothing // do nothing

66
designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java

@ -7,12 +7,22 @@ import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location; import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.XConnector;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import java.awt.*; import java.awt.Component;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -94,8 +104,11 @@ public class StateModel {
return; return;
} }
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); XLayoutContainer container = getMouseLocationContainer(e);
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); if (container == null) {
return;
}
XCreator creator = selectionModel.getSelection().getSelectedCreator(); XCreator creator = selectionModel.getSelection().getSelectedCreator();
Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator); Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator);
if (creatorContainer != null && creatorContainer != container if (creatorContainer != null && creatorContainer != container
@ -141,11 +154,8 @@ public class StateModel {
* @param mouseReleasedY 鼠标释放位置Y * @param mouseReleasedY 鼠标释放位置Y
*/ */
private void adding(int mouseReleasedX, int mouseReleasedY) { private void adding(int mouseReleasedX, int mouseReleasedY) {
// 当前鼠标所在的组件 // 当前鼠标所在组件的容器
XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators()); XLayoutContainer container = getMouseLocationContainer(mouseReleasedX, mouseReleasedY);
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
boolean success = false; boolean success = false;
@ -166,6 +176,33 @@ public class StateModel {
designer.setPainter(null); designer.setPainter(null);
} }
/**
* 获取鼠标所在位置组件的容器
*
* @param e MouseEvent
* @return 鼠标所在位置的组件的容器
*/
private XLayoutContainer getMouseLocationContainer(MouseEvent e) {
return getMouseLocationContainer(e.getX(), e.getY());
}
/**
* 获取鼠标所在位置组件的容器
*
* @param x x 鼠标所在位置x
* @param y y 鼠标所在位置y
* @return 鼠标所在位置的组件的容器
*/
private XLayoutContainer getMouseLocationContainer(int x, int y) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(x, y, selectionModel.getSelection().getSelectedCreators());
if (hoveredComponent == null) {
return null;
}
// 获取该组件所在的焦点容器
return XCreatorUtils.getHotspotContainer(hoveredComponent);
}
/** /**
* 是否拖拽 * 是否拖拽
* *
@ -246,7 +283,7 @@ public class StateModel {
if (p != null) { if (p != null) {
try { try {
designer.setCursor(XConnector.connectorCursor); designer.setCursor(XConnector.connectorCursor);
} catch (Exception e) { } catch (Exception ignored) {
} }
} else { } else {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
@ -433,11 +470,11 @@ public class StateModel {
// 拖拽时画依附线用到的painter // 拖拽时画依附线用到的painter
private void setDependLinePainter(MouseEvent e) { private void setDependLinePainter(MouseEvent e) {
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); XLayoutContainer container = getMouseLocationContainer(e);
if (comp == null) { if (container == null) {
return; return;
} }
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator(); XCreator creator = selectionModel.getSelection().getSelectedCreator();
HoverPainter painter = AdapterBus.getContainerPainter(designer, container); HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
designer.setPainter(painter); designer.setPainter(painter);
@ -479,9 +516,8 @@ public class StateModel {
* @return xy值 * @return xy值
*/ */
public Point getMouseXY(MouseEvent e) { public Point getMouseXY(MouseEvent e) {
Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY() return new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY()
+ designer.getArea().getVerticalValue()); + designer.getArea().getVerticalValue());
return p1;
} }
} }

4
designer-form/src/main/java/com/fr/design/designer/creator/ErrorCreator.java

@ -1,7 +1,7 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.form.ui.ErrorMarker;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetErrorMarker;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.awt.*; import java.awt.*;
@ -18,7 +18,7 @@ public class ErrorCreator extends NullCreator {
@Override @Override
protected String showText() { protected String showText() {
ErrorMarker marker = (ErrorMarker)toData(); WidgetErrorMarker marker = (WidgetErrorMarker)toData();
String text = marker.getWidgetValue().getDisplayValue(); String text = marker.getWidgetValue().getDisplayValue();
if (StringUtils.isEmpty(text)) { if (StringUtils.isEmpty(text)) {
return super.showText(); return super.showText();

12
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -26,7 +26,6 @@ import com.fr.form.ui.ComboCheckBox;
import com.fr.form.ui.DateEditor; import com.fr.form.ui.DateEditor;
import com.fr.form.ui.EditorHolder; import com.fr.form.ui.EditorHolder;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.ErrorMarker;
import com.fr.form.ui.FileEditor; import com.fr.form.ui.FileEditor;
import com.fr.form.ui.FreeButton; import com.fr.form.ui.FreeButton;
import com.fr.form.ui.IframeEditor; import com.fr.form.ui.IframeEditor;
@ -42,6 +41,7 @@ import com.fr.form.ui.TextEditor;
import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeComboBoxEditor;
import com.fr.form.ui.TreeEditor; import com.fr.form.ui.TreeEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetErrorMarker;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
@ -66,9 +66,11 @@ 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.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.javax.annotation.Nonnull;
import javax.swing.*; import javax.swing.Icon;
import java.awt.*; import java.awt.Container;
import java.awt.Dimension;
/** /**
* XCreator的相关处理 * XCreator的相关处理
@ -158,7 +160,7 @@ public class XCreatorUtils {
objectMap.put(NameWidget.class, XNameWidget.class); objectMap.put(NameWidget.class, XNameWidget.class);
objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); objectMap.put(CardSwitchButton.class, XCardSwitchButton.class);
objectMap.put(CardAddButton.class, XCardAddButton.class); objectMap.put(CardAddButton.class, XCardAddButton.class);
objectMap.put(ErrorMarker.class, ErrorCreator.class); objectMap.put(WidgetErrorMarker.class, ErrorCreator.class);
} }
private static void reInitExtra() { private static void reInitExtra() {
@ -284,7 +286,7 @@ public class XCreatorUtils {
* @param creator 组件 * @param creator 组件
* @return 返回顶层容器 * @return 返回顶层容器
*/ */
public static XLayoutContainer getHotspotContainer(XCreator creator) { public static XLayoutContainer getHotspotContainer(@Nonnull XCreator creator) {
if (creator.isDedicateContainer()) { if (creator.isDedicateContainer()) {
return (XLayoutContainer) creator.getParent(); return (XLayoutContainer) creator.getParent();
} }

4
designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java

@ -68,7 +68,9 @@ public class XNameWidget extends XWidgetCreator {
Widget widget; Widget widget;
if (wc != null && (widget= wc.toWidget()) != null) { if (wc != null && (widget= wc.toWidget()) != null) {
editor = XCreatorUtils.createXCreator(widget); editor = XCreatorUtils.createXCreator(widget);
toData().setVisible(widget.isVisible()); Widget currentWidget = toData();
currentWidget.setVisible(widget.isVisible());
currentWidget.setEnabled(widget.isEnabled());
this.setBorder(null); this.setBorder(null);
} else { } else {
this.setBorder(DEFALUTBORDER); this.setBorder(DEFALUTBORDER);

13
designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java

@ -10,6 +10,7 @@ import java.awt.event.ContainerEvent;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRScaleLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRScaleLayoutAdapter;
import com.fr.design.form.layout.FRScaleLayout; import com.fr.design.form.layout.FRScaleLayout;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
@ -166,4 +167,16 @@ public class XWScaleLayout extends DedicateLayoutContainer {
XCreator child = getXCreator(INDEX); XCreator child = getXCreator(INDEX);
child.firePropertyChange(); child.firePropertyChange();
} }
/**
* 获取被包装的XCreator扩展的属性tab
* @return
*/
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
if (this.getXCreatorCount() > 0) {
return this.getXCreator(0).getWidgetPropertyUIProviders();
}
return super.getWidgetPropertyUIProviders();
}
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -106,6 +106,16 @@ public class XWCardLayout extends XLayoutContainer {
return new Dimension(500, 300); return new Dimension(500, 300);
} }
/**
* 重置组件的名称
* @param name 名称
*/
public void resetCreatorName(String name) {
super.resetCreatorName(name);
changeRelateSwitchCardName(name);
}
@Override @Override
protected void initLayoutManager() { protected void initLayoutManager() {
cardLayout = new FRCardLayout(toData().getHgap(), toData().getVgap()); cardLayout = new FRCardLayout(toData().getHgap(), toData().getVgap());

8
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -11,6 +11,7 @@ import java.awt.Image;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -324,10 +325,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
*/ */
public UpdateAction[] getActions() { public UpdateAction[] getActions() {
if (designerActions == null) { if (designerActions == null) {
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this), designerActions = new ArrayList<UpdateAction>(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)}; new FormDeleteAction(this)}));
dmlActions(designerActions);
} }
return designerActions; return designerActions.toArray(new UpdateAction[designerActions.size()]);
} }
private boolean searchQueryCreators(XLayoutContainer rootContainer) { private boolean searchQueryCreators(XLayoutContainer rootContainer) {

30
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -3,19 +3,28 @@ package com.fr.design.mainframe;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.itree.UITreeUI; import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.DropMode;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel; import javax.swing.tree.TreeSelectionModel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -118,7 +127,9 @@ public class ComponentTree extends JTree {
public void setAndScrollSelectionPath(TreePath[] treepath) { public void setAndScrollSelectionPath(TreePath[] treepath) {
setSelectionPaths(treepath); setSelectionPaths(treepath);
scrollPathToVisible(treepath[0]); if (treepath.length > 0) {
scrollPathToVisible(treepath[0]);
}
} }
@Override @Override
@ -330,8 +341,7 @@ public class ComponentTree extends JTree {
return contentPane; return contentPane;
} }
private BufferedImage componentToImage(Component comp) throws IOException private BufferedImage componentToImage(Component comp) throws IOException {
{
BufferedImage im = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_ARGB); BufferedImage im = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_ARGB);
comp.paint(im.getGraphics()); comp.paint(im.getGraphics());
return im; return im;
@ -341,14 +351,14 @@ public class ComponentTree extends JTree {
private void updateSize() { private void updateSize() {
int width = compImage.getWidth(); int width = compImage.getWidth();
int height = compImage.getHeight(); int height = compImage.getHeight();
double aspectRatio = (double)width / height; double aspectRatio = (double) width / height;
if (width > MAX_WIDTH) { if (width > MAX_WIDTH) {
width = MAX_WIDTH; width = MAX_WIDTH;
height = (int)(width / aspectRatio); height = (int) (width / aspectRatio);
} }
if (height > MAX_HEIGHT) { if (height > MAX_HEIGHT) {
height = MAX_HEIGHT; height = MAX_HEIGHT;
width = (int)(height * aspectRatio); width = (int) (height * aspectRatio);
} }
this.setPreferredSize(new Dimension(width, height)); this.setPreferredSize(new Dimension(width, height));
} }

35
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1,9 +1,11 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.FRContext;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
@ -39,6 +41,7 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
@ -62,6 +65,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.third.javax.annotation.Nullable;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -89,6 +93,7 @@ import java.lang.reflect.Proxy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 设计界面组件该组件是界面设计工具的核心主要负责的是被设计界面的显示界面设计操作状态的 显示编辑状态的显示等等 * 设计界面组件该组件是界面设计工具的核心主要负责的是被设计界面的显示界面设计操作状态的 显示编辑状态的显示等等
@ -132,7 +137,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private int resolution = ScreenResolution.getScreenResolution(); private int resolution = ScreenResolution.getScreenResolution();
// 编辑状态的事件表 // 编辑状态的事件表
private CreatorEventListenerTable edit; private CreatorEventListenerTable edit;
protected UpdateAction[] designerActions; protected List<UpdateAction> designerActions;
private FormDesignerModeForSpecial<?> desigerMode; private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction; private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer; private FormElementCaseContainerProvider elementCaseContainer;
@ -914,7 +919,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isRoot(XCreator comp) { public boolean isRoot(XCreator comp) {
return comp == rootComponent || comp.acceptType(XWAbsoluteBodyLayout.class); return comp != null && (comp == rootComponent || comp.acceptType(XWAbsoluteBodyLayout.class));
} }
// 计算鼠标事件e所发生的位置相对根组件的位置关系 // 计算鼠标事件e所发生的位置相对根组件的位置关系
@ -976,6 +981,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return getComponentAt(x, y, null); return getComponentAt(x, y, null);
} }
@Nullable
public XCreator getComponentAt(int x, int y, XCreator[] except) { public XCreator getComponentAt(int x, int y, XCreator[] except) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
XCreator comp = xCreatorAt(x + formArea.getHorizontalValue(), y + formArea.getVerticalValue(), container, XCreator comp = xCreatorAt(x + formArea.getHorizontalValue(), y + formArea.getVerticalValue(), container,
@ -1180,11 +1186,30 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*/ */
public UpdateAction[] getActions() { public UpdateAction[] getActions() {
if (designerActions == null) { if (designerActions == null) {
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this), designerActions = new ArrayList<UpdateAction>(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this), new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this),
new MoveUpAction(this), new MoveDownAction(this)}; new MoveUpAction(this), new MoveDownAction(this)}));
dmlActions(designerActions);
}
return designerActions.toArray(new UpdateAction[designerActions.size()]);
}
/**
* 扩展菜单项
*
* @param actions
*/
public void dmlActions(List<UpdateAction> actions) {
try {
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) {
handler.dmlUpdateActions(this, actions);
}
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
} }
return designerActions;
} }
// 当前选中控件可以上移一层吗? // 当前选中控件可以上移一层吗?

187
designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java

@ -12,7 +12,6 @@ import com.fr.form.ui.DataControl;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.MultiFileEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.js.WidgetName; import com.fr.stable.js.WidgetName;
@ -20,35 +19,38 @@ import com.fr.stable.js.WidgetName;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> { public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>> {
public FormModelAdapter(BaseJForm jForm) { public FormModelAdapter(BaseJForm<Form> jForm) {
super(jForm); super(jForm);
} }
/** /**
* 环境改变. * 环境改变.
*/ */
public void envChanged() { public void envChanged() {
WidgetToolBarPane.refresh(); WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets(); jTemplate.refreshAllNameWidgets();
}
}
/** /**
* 参数改变. * 参数改变.
*/ */
public void parameterChanged() { public void parameterChanged() {
//实时更新参数 //实时更新参数
jTemplate.populateParameter(); jTemplate.populateParameter();
} // 更新缓存的参数
updateCachedParameter();
}
/** /**
* 控件配置改变. * 控件配置改变.
*/ */
public void widgetConfigChanged() { public void widgetConfigChanged() {
WidgetToolBarPane.refresh(); WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets(); jTemplate.refreshAllNameWidgets();
} }
/** /**
* 重命名TableData后的一些操作 * 重命名TableData后的一些操作
@ -57,81 +59,80 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
* @param newName 新名字. * @param newName 新名字.
* @return 返回是否名字一样. * @return 返回是否名字一样.
*/ */
public boolean renameTableData(String oldName, String newName) { public boolean renameTableData(String oldName, String newName) {
if (super.renameTableData(oldName, newName)) { if (super.renameTableData(oldName, newName)) {
jTemplate.refreshSelectedWidget(); jTemplate.refreshSelectedWidget();
return true; return true;
} }
return false; return false;
} }
@Override @Override
public List<WidgetName> getWidgetsName() { public List<WidgetName> getWidgetsName() {
final List<WidgetName> list = new ArrayList<WidgetName>(); final List<WidgetName> list = new ArrayList<WidgetName>();
Form.traversalFormWidget(this.getBook().getContainer(), new WidgetGatherAdapter() { Form.traversalFormWidget(this.getBook().getContainer(), new WidgetGatherAdapter() {
@Override @Override
public void dealWith(Widget widget) { public void dealWith(Widget widget) {
if (widget instanceof DataControl || widget instanceof MultiFileEditor) { if (widget instanceof DataControl || widget instanceof MultiFileEditor) {
list.add(new WidgetName(widget.getWidgetName())); list.add(new WidgetName(widget.getWidgetName()));
} }
} }
}); });
return list; return list;
} }
/** /**
* 获取可以被超链的对象,表单主体中的所有控件 * 获取可以被超链的对象,表单主体中的所有控件
*/ */
public Widget[] getLinkableWidgets() { public Widget[] getLinkableWidgets() {
final ArrayList<Widget> linkAbleList = new ArrayList<Widget>(); final ArrayList<Widget> linkAbleList = new ArrayList<Widget>();
final JForm currentJForm = ((JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); final JForm currentJForm = ((JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
Form.traversalWidget(currentJForm.getRootLayout(), new WidgetGatherAdapter() { Form.traversalWidget(currentJForm.getRootLayout(), new WidgetGatherAdapter() {
@Override @Override
public boolean dealWithAllCards() { public boolean dealWithAllCards() {
return true; return true;
} }
public void dealWith(Widget widget) { public void dealWith(Widget widget) {
boolean isSupportAsHypelink = widget.acceptType(ElementCaseEditor.class) || widget.acceptType(BaseChartEditor.class); boolean isSupportAsHypelink = widget.acceptType(ElementCaseEditor.class) || widget.acceptType(BaseChartEditor.class);
//可以超链的对象不包含本身; 目前只有图表和报表块可以 //可以超链的对象不包含本身; 目前只有图表和报表块可以
// bug66182 删了条件:!ComparatorUtils.equals(editingECName, widget.getWidgetName()) 让当前表单对象可以选到自己 // bug66182 删了条件:!ComparatorUtils.equals(editingECName, widget.getWidgetName()) 让当前表单对象可以选到自己
if (isSupportAsHypelink) { if (isSupportAsHypelink) {
linkAbleList.add(widget); linkAbleList.add(widget);
} }
} }
}, Widget.class); }, Widget.class);
return linkAbleList.toArray(new Widget[linkAbleList.size()]); return linkAbleList.toArray(new Widget[linkAbleList.size()]);
} }
// 报表参数
@Override @Override
public Parameter[] getReportParameters() { protected Parameter[] getLatestTemplateParameters() {
Parameter[] rpa = this.getBook().getTemplateParameters(); Parameter[] rpa = this.getBook().getTemplateParameters();
return rpa == null ? new Parameter[0] : rpa; return rpa == null ? new Parameter[0] : rpa;
} }
// 数据源参数 @Override
@Override protected Parameter[] getLatestTableDataParameters() {
public Parameter[] getTableDataParameters() { TableDataSource source = this.getBook();
TableDataSource source = this.getBook(); Calculator c = Calculator.createCalculator();
Calculator c = Calculator.createCalculator(); c.setAttribute(TableDataSource.KEY, source);
c.setAttribute(TableDataSource.KEY, source); java.util.List<ParameterProvider> list = new java.util.ArrayList<ParameterProvider>();
java.util.List<ParameterProvider> list = new java.util.ArrayList<ParameterProvider>(); java.util.Iterator<String> nameIt = this.getBook().getTableDataNameIterator();
java.util.Iterator<String> nameIt = this.getBook().getTableDataNameIterator(); while (nameIt.hasNext()) {
while (nameIt.hasNext()) { TableData td = source.getTableData(nameIt.next());
TableData td = source.getTableData(nameIt.next()); if (td.getParameters(c) != null) {
if (td.getParameters(c) != null) { list.addAll(java.util.Arrays.asList(td.getParameters(c)));
list.addAll(java.util.Arrays.asList(td.getParameters(c))); }
} }
} return list.toArray(new Parameter[list.size()]);
return list.toArray(new Parameter[list.size()]); }
}
@Override
@Override protected Parameter[] getLatestParameters() {
public Parameter[] getParameters() { return this.getBook().getParameters();
return this.getBook().getParameters(); }
}
} }

56
designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

@ -14,12 +14,11 @@ import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.awt.Component; import java.awt.Component;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -97,8 +96,7 @@ public class FormSelectionUtils {
Rectangle rec = clipboard.getSelctionBounds(); Rectangle rec = clipboard.getSelctionBounds();
for (XCreator creator : clipboard.getSelectedCreators()) { for (XCreator creator : clipboard.getSelectedCreators()) {
try { try {
Widget copied = copyWidget(designer, creator); XCreator copiedCreator = copyXcreator(designer.getTarget(), creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
// 获取位置 // 获取位置
Point point = getPasteLocation((AbstractLayoutAdapter) adapter, Point point = getPasteLocation((AbstractLayoutAdapter) adapter,
copiedCreator, copiedCreator,
@ -181,8 +179,7 @@ public class FormSelectionUtils {
private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) { private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) {
try { try {
Widget copied = copyWidget(designer, creator); XCreator copiedXCreator = copyXcreator(designer.getTarget(), creator);
XCreator copiedXCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) { if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
if (!adapter.accept(copiedXCreator, x - tabContainerRect.x, y - tabContainerRect.y)) { if (!adapter.accept(copiedXCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
designer.showMessageDialog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Too_Small_To_Paste")); designer.showMessageDialog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Too_Small_To_Paste"));
@ -235,33 +232,52 @@ public class FormSelectionUtils {
return new Point(x, y); return new Point(x, y);
} }
/** /**
* 拷贝组件 * 拷贝组件
* @param form 当前表单
* @param xCreator 待拷贝的组件
* @return XCreator 拷贝的组件
*/ */
private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws public static XCreator copyXcreator(Form form, XCreator xCreator) throws CloneNotSupportedException{
CloneNotSupportedException {
ArrayList<String> nameSpace = new ArrayList<>();
Widget copied = (Widget) xCreator.toData().clone(); Widget copied = (Widget) xCreator.toData().clone();
//重命名拷贝的组件 XCreator copiedCreator = XCreatorUtils.createXCreator(copied, xCreator.getSize());
String name = getCopiedName(formDesigner, copied, nameSpace); ArrayList<String> nameSpace = new ArrayList<>();
if (copied instanceof WTitleLayout) { copyWidgetName(form, nameSpace, copiedCreator);
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) copied, xCreator.getSize()); return copiedCreator;
xwTitleLayout.resetCreatorName(name); }
} else {
copied.setWidgetName(name); /**
* 拷贝组件
* @param form 当前表单
* @param nameSpace 命名空间
* @param xCreator 拷贝的组件
*/
private static void copyWidgetName(Form form, ArrayList<String> nameSpace, XCreator xCreator){
String copyName = FormSelectionUtils.getCopiedName(form, xCreator.toData(), nameSpace);
if (xCreator.toData() instanceof WTitleLayout) {
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) xCreator.toData(), xCreator.getSize());
xwTitleLayout.resetCreatorName(copyName);
return;
}
xCreator.resetCreatorName(copyName);
int count = xCreator.getComponentCount();
for(int a = 0; a <count; a++){
if(xCreator.getComponent(a) instanceof XCreator){
XCreator child = (XCreator)xCreator.getComponent(a);
copyWidgetName(form, nameSpace, child);
}
} }
return copied;
} }
/** /**
* 组件拷贝命名规则 * 组件拷贝命名规则
*/ */
private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> nameSpace) { private static String getCopiedName(Form form, Widget copied, ArrayList<String> nameSpace) {
StringBuilder name = new StringBuilder(copied.getWidgetName()); StringBuilder name = new StringBuilder(copied.getWidgetName());
do { do {
name.append(POSTFIX); name.append(POSTFIX);
} while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString())); } while (form.isNameExist(name.toString()) || nameSpace.contains(name.toString()));
nameSpace.add(name.toString()); nameSpace.add(name.toString());
return name.toString(); return name.toString();
} }

11
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -5,6 +5,7 @@ import com.fr.base.PaperSize;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.actions.FormMobileAttrAction;
import com.fr.design.actions.TemplateParameterAction; import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.export.EmbeddedFormExportExportAction; import com.fr.design.actions.file.export.EmbeddedFormExportExportAction;
@ -86,7 +87,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm { public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form> {
private static final String FORM_CARD = "FORM"; private static final String FORM_CARD = "FORM";
private static final String ELEMENTCASE_CARD = "ELEMENTCASE"; private static final String ELEMENTCASE_CARD = "ELEMENTCASE";
@ -139,7 +140,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return DesignState.JFORM; return DesignState.JFORM;
} }
public TemplateProcessInfo getProcessInfo() { public TemplateProcessInfo<Form> getProcessInfo() {
if (processInfo == null) { if (processInfo == null) {
processInfo = new JFormProcessInfo(template); processInfo = new JFormProcessInfo(template);
} }
@ -160,7 +161,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
} }
@Override @Override
protected boolean accept(Object o) { public boolean accept(Object o) {
return !(o instanceof FloatElementsProvider); return !(o instanceof FloatElementsProvider);
} }
@ -496,9 +497,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override @Override
public ShortCut[] shortcut4TemplateMenu() { public ShortCut[] shortcut4TemplateMenu() {
if (this.index == FORM_TAB) { if (this.index == FORM_TAB) {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, new ShortCut[0]); return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new FormMobileAttrAction(this), new ReportFitAttrAction(this)}, new ShortCut[0]);
} else { } else {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu()); return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new FormMobileAttrAction(this), new ReportFitAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu());
} }
} }

11
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -137,14 +137,9 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
XLayoutContainer rootLayout = selectedBodyLayout(formDesigner); XLayoutContainer rootLayout = selectedBodyLayout(formDesigner);
if (rootLayout != formDesigner.getRootComponent() if (rootLayout != formDesigner.getRootComponent()
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) { && formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) {
//原单例面板populate根据当前样式populate属性面板,现加入移动端逻辑:可能需要根据面板属性改变样式 formDesigner.getSelectionModel().setSelectedCreators(
Form form = formDesigner.getTarget(); FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
if (form.getFormMobileAttr().isMobileOnly() && form.getFormMobileAttr().isAdaptivePropertyAutoMatch()) {
((XWFitLayout)formDesigner.getRootComponent()).switch2FitBodyLayout(rootLayout);
} else {
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
}
} }
paddingBound.populate(ob); paddingBound.populate(ob);
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue()); layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());

5
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java

@ -115,6 +115,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
templateStyleEditor.setValue(ob.getTemplateStyle()); templateStyleEditor.setValue(ob.getTemplateStyle());
FRFont frFont = layoutBorderStyle.getTitle().getFrFont(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont();
if (frFont != null) { if (frFont != null) {
ob.setTitleFont(frFont);
frFontPane.populateBean(frFont); frFontPane.populateBean(frFont);
} }
} }
@ -126,8 +127,10 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart(); XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart();
LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle(); LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle();
FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont();
layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont)); FRFont titleFont = frFontPane.update(frFont);
layoutBorderStyle.getTitle().setFrFont(titleFont);
WCardTagLayout layout = (WCardTagLayout) creator.toData(); WCardTagLayout layout = (WCardTagLayout) creator.toData();
layout.setTitleFont(titleFont);
boolean isHori = displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.TOP_POSITION.getType() || displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.BOTTOM_POSITION.getType(); boolean isHori = displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.TOP_POSITION.getType() || displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.BOTTOM_POSITION.getType();
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template"))) { if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template"))) {
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));

2
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java

@ -218,7 +218,7 @@ public class ParaMobileDefinePane extends MobileWidgetDefinePane {
break; break;
} }
} }
} catch (JSONException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
paramLocationComboBox.setSelectedIndex(index); paramLocationComboBox.setSelectedIndex(index);

29
designer-form/src/test/java/com/fr/form/ui/WidgetNameCopyTest.java

@ -0,0 +1,29 @@
package com.fr.form.ui;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.form.main.Form;
import com.fr.general.ComparatorUtils;
import junit.framework.TestCase;
import java.awt.Dimension;
/**
* @author kerry
* @date 2018/7/27
*/
public class WidgetNameCopyTest extends TestCase {
public void testWidgetNameCopy() throws Exception {
Widget button = new FreeButton();
Form form = new Form();
button.setWidgetName("button0");
XCreator xCreator = XCreatorUtils.createXCreator(button, new Dimension(100, 100));
XCreator copyXcreator1 = FormSelectionUtils.copyXcreator(form, xCreator);
XCreator copyXcreator2 = FormSelectionUtils.copyXcreator(form, xCreator);
copyXcreator1.toData().setWidgetName("button_test");
assertTrue(!ComparatorUtils.equals(copyXcreator2.toData().getWidgetName(), copyXcreator1.toData().getWidgetName()));
}
}

22
designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java

@ -3,25 +3,25 @@
*/ */
package com.fr.design.actions.report; package com.fr.design.actions.report;
import java.awt.event.ActionEvent;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.JWorkBookAction; import com.fr.design.actions.JWorkBookAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.parameter.ParameterArrayPane; import com.fr.design.parameter.ParameterArrayPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.main.TemplateWorkBook; import com.fr.main.TemplateWorkBook;
import com.fr.main.parameter.ReportParameterAttr; import com.fr.main.parameter.ReportParameterAttr;
import javax.swing.SwingUtilities;
import java.awt.event.ActionEvent;
/** /**
* Report Parameter * Report Parameter
*/ */
public class ReportParameterAction extends JWorkBookAction{ public class ReportParameterAction extends JWorkBookAction {
public ReportParameterAction(JWorkBook jwb) { public ReportParameterAction(JWorkBook jwb) {
super(jwb); super(jwb);
@ -37,7 +37,7 @@ public class ReportParameterAction extends JWorkBookAction{
* @return 是否执行成功 * @return 是否执行成功
*/ */
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
final JWorkBook jwb = getEditingComponent(); JWorkBook jwb = getEditingComponent();
if (jwb == null) { if (jwb == null) {
return; return;
} }
@ -59,10 +59,8 @@ public class ReportParameterAction extends JWorkBookAction{
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
copyReportParameterAttr.addParameter(parameters[i]); copyReportParameterAttr.addParameter(parameters[i]);
} }
jwb.fireTargetModified(); DesignModelAdapter.getCurrentModelAdapter().fireTargetModified();
jwb.updateReportParameterAttr(); DesignModelAdapter.getCurrentModelAdapter().parameterChanged();
jwb.populateReportParameterAttr();
} }
}); });
parameterArrayDialog.setVisible(true); parameterArrayDialog.setVisible(true);

75
designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java

@ -10,8 +10,11 @@ import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
import com.fr.transaction.WorkerCallBack;
import com.fr.transaction.WorkerFacade;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -21,16 +24,17 @@ import java.awt.event.ActionEvent;
* StyleList Action * StyleList Action
*/ */
public class StyleListAction extends UpdateAction { public class StyleListAction extends UpdateAction {
public StyleListAction() { public StyleListAction() {
this.setMenuKeySet(PREDEFINED_STYLES); this.setMenuKeySet(PREDEFINED_STYLES);
this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png")); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png"));
this.generateAndSetSearchText(StyleManagerPane.class.getName()); this.generateAndSetSearchText(StyleManagerPane.class.getName());
} }
/** /**
* 动作 * 动作
*
* @param evt 事件 * @param evt 事件
*/ */
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
@ -40,45 +44,44 @@ public class StyleListAction extends UpdateAction {
styleListDialog.addDialogActionListener(new DialogActionAdapter() { styleListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
Configurations.update(new Worker() { Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) {
@Override @Override
public void run() { public void run() {
styleListPane.update(ServerPreferenceConfig.getInstance()); styleListPane.update(ServerPreferenceConfig.getInstance());
} }
}.addCallBack(new CallBackAdaptor(){
@Override
public void afterCommit() {
DesignerContext.getDesignerBean("predefinedStyle").refreshBeanElement();
}
}));
@Override }
public Class<? extends Configuration>[] targets() {
return new Class[]{ServerPreferenceConfig.class};
}
});
}
}); });
ServerPreferenceConfig mirror = ServerPreferenceConfig.getInstance().mirror(); ServerPreferenceConfig mirror = ServerPreferenceConfig.getInstance().mirror();
styleListPane.populate(mirror); styleListPane.populate(mirror);
styleListDialog.setVisible(true); styleListDialog.setVisible(true);
}
}
@Override @Override
public void update() { public void update() {
this.setEnabled(true); this.setEnabled(true);
} }
public static final MenuKeySet PREDEFINED_STYLES = new MenuKeySet() { public static final MenuKeySet PREDEFINED_STYLES = new MenuKeySet() {
@Override @Override
public char getMnemonic() { public char getMnemonic() {
return 'K'; return 'K';
} }
@Override @Override
public String getMenuName() { public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles");
} }
@Override @Override
public KeyStroke getKeyStroke() { public KeyStroke getKeyStroke() {
return null; return null;
} }
}; };
} }

48
designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java

@ -3,9 +3,6 @@
*/ */
package com.fr.design.cell.clipboard; package com.fr.design.cell.clipboard;
import java.util.Arrays;
import java.util.Iterator;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
@ -15,6 +12,9 @@ import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.unit.FU; import com.fr.stable.unit.FU;
import java.util.Arrays;
import java.util.Iterator;
/** /**
* The clip of CellElement. * The clip of CellElement.
*/ */
@ -39,7 +39,47 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
this.clips = clips; this.clips = clips;
} }
public String compateExcelPaste() { public int getColumnSpan() {
return columnSpan;
}
public void setColumnSpan(int columnSpan) {
this.columnSpan = columnSpan;
}
public int getRowSpan() {
return rowSpan;
}
public void setRowSpan(int rowSpan) {
this.rowSpan = rowSpan;
}
public FU[] getColumnWidth() {
return columnWidth;
}
public void setColumnWidth(FU[] columnWidth) {
this.columnWidth = columnWidth;
}
public FU[] getRowHeight() {
return rowHeight;
}
public void setRowHeight(FU[] rowHeight) {
this.rowHeight = rowHeight;
}
public TemplateCellElement[] getClips() {
return clips;
}
public void setClips(TemplateCellElement[] clips) {
this.clips = clips;
}
public String compateExcelPaste() {
Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator()); Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator());
// 排序 // 排序

2
designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java

@ -67,7 +67,7 @@ public class CellElementPropertyPane extends DockingView {
} }
public synchronized static CellElementPropertyPane getInstance() { public static CellElementPropertyPane getInstance() {
if (singleton == null) { if (singleton == null) {
synchronized (CellElementPropertyPane.class) { synchronized (CellElementPropertyPane.class) {
if (singleton == null) { if (singleton == null) {

3
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -663,7 +663,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
} }
} }
private Object getClipObject() { public Object getClipObject() {
// 需要检查是否可以编辑。 // 需要检查是否可以编辑。
Clipboard clipboard = DesignerContext.getClipboard(this.getGrid()); Clipboard clipboard = DesignerContext.getClipboard(this.getGrid());
Transferable clipData = clipboard.getContents(this); Transferable clipData = clipboard.getContents(this);
@ -862,6 +862,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
/** /**
* 响应目标变动. * 响应目标变动.
*/ */
@Override
public void fireTargetModified() { public void fireTargetModified() {
// marks:自动计算 // marks:自动计算
TemplateElementCase report = this.getEditingElementCase(); TemplateElementCase report = this.getEditingElementCase();

314
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -5,11 +5,6 @@ package com.fr.design.mainframe;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.core.db.dml.Delete;
import com.fr.data.core.db.dml.Select;
import com.fr.data.core.db.dml.Table;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
@ -19,18 +14,13 @@ import com.fr.general.DateUtils;
import com.fr.general.DesUtils; import com.fr.general.DesUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
import com.fr.intelli.record.FocusPoint; import com.fr.intelli.record.FocusPoint;
import com.fr.intelli.record.MetricException;
import com.fr.intelli.record.MetricRegistry; import com.fr.intelli.record.MetricRegistry;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; 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.log.message.ParameterMessage;
import com.fr.record.DBRecordXManager;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -58,17 +48,15 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
/** /**
* @author neil * @author neil
@ -79,7 +67,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
// 24小时上传一次 // 24小时上传一次
private static final long DELTA = 24 * 3600 * 1000L; private static final long DELTA = 24 * 3600 * 1000L;
private static final long SEND_DELAY = 30 * 1000L; private static final long SEND_DELAY = 300 * 1000L;
private static final String FILE_NAME = "fr.info"; private static final String FILE_NAME = "fr.info";
private static final String XML_START_STOP_LIST = "StartStopList"; private static final String XML_START_STOP_LIST = "StartStopList";
private static final String XML_START_STOP = "StartStop"; private static final String XML_START_STOP = "StartStop";
@ -101,9 +89,15 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private static final String ATTR_TEXT = "text"; private static final String ATTR_TEXT = "text";
private static final String ATTR_SOURCE = "source"; private static final String ATTR_SOURCE = "source";
private static final String ATTR_TIME = "time"; private static final String ATTR_TIME = "time";
private static final String ATTR_TIMES = "times";
private static final String ATTR_TITLE = "title"; private static final String ATTR_TITLE = "title";
private static final String ATTR_USER_NAME = "username"; private static final String ATTR_USER_NAME = "username";
private static final String ATTR_UUID = "uuid"; private static final String ATTR_UUID = "uuid";
private static final String ATTR_ITEMS = "items";
private static final String ATTR_FUNCTION_ARRAY = "functionArray";
private static final int MAX_EACH_REQUEST_RECORD_COUNT = 200;
private static final int PAGE_SIZE = 200;
private long totalCount = -1;
private static InformationCollector collector; private static InformationCollector collector;
@ -168,35 +162,25 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private byte[] getJSONContentAsByte(){ private JSONObject getJSONContentAsByte(){
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray(); JSONArray startStopArray = new JSONArray();
for (int i = 0; i < startStop.size(); i++) { for (int i = 0; i < startStop.size(); i++) {
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
try { jo.put(ATTR_START, startStop.get(i).getStartDate());
jo.put(ATTR_START, startStop.get(i).getStartDate()); jo.put(ATTR_STOP, startStop.get(i).getStopDate());
jo.put(ATTR_STOP, startStop.get(i).getStopDate()); startStopArray.put(jo);
startStopArray.put(jo); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); content.put(XML_START_STOP, startStopArray);
content.put(XML_START_STOP, startStopArray); content.put(XML_UUID, envManager.getUUID());
content.put(XML_UUID, envManager.getUUID()); content.put(XML_JAR, GeneralUtils.readBuildNO());
content.put(XML_JAR, GeneralUtils.readBuildNO()); content.put(XML_VERSION, ProductConstants.RELEASE_VERSION);
content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername());
content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); content.put(XML_KEY, envManager.getActivationKey());
content.put(XML_KEY, envManager.getActivationKey()); content.put(XML_OS, System.getProperty("os.name"));
content.put(XML_OS, System.getProperty("os.name"));
} catch (JSONException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
try {
return content.toString().getBytes(EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().error(e.getMessage(), e);
return ArrayUtils.EMPTY_BYTE_ARRAY;
} }
return content;
} }
private void sendUserInfo(){ private void sendUserInfo(){
@ -206,19 +190,17 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) { if (currentTime - lastTime <= DELTA) {
return; return;
} }
byte[] content = getJSONContentAsByte(); JSONObject content = getJSONContentAsByte();
HttpClient hc = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("user.info")); String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
hc.setContent(content);
if (!hc.isServerAlive()) {
return;
}
String res = hc.getResponseText();
//服务器返回true,说明已经取得成功,清空当前记录的信息
boolean success = false; boolean success = false;
try { try {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (JSONException e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (success){ if (success){
this.reset(); this.reset();
@ -232,21 +214,14 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) { if (currentTime - lastTime <= DELTA) {
return; return;
} }
ArrayList<Map<String, Object>> content = null;
content = getFunctionsContent(current, new Date(lastTime));
boolean success = false;
FineLoggerFactory.getLogger().info("Start sent function records to the cloud center..."); FineLoggerFactory.getLogger().info("Start sent function records to the cloud center...");
String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD); queryAndSendOnePageFunctionContent(currentTime, lastTime, 0);
if(content.size() > 0){ long page = (totalCount/PAGE_SIZE) + 1;
for(int i=0; i<content.size(); i++){ for(int i=1; i<page; i++){
success = sendFunctionRecord(url, content.get(i)); queryAndSendOnePageFunctionContent(currentTime, lastTime, i);
}
//服务器返回true, 说明已经获取成功, 更新最后一次发送时间
if (success) {
this.lastTime = dateToString();
}
} }
FineLoggerFactory.getLogger().info("Function records successfully sent to the cloud center.");
// //先将发送压缩文件这段代码注释,之后提任务 // //先将发送压缩文件这段代码注释,之后提任务
//大数据量下发送压缩zip数据不容易丢失 //大数据量下发送压缩zip数据不容易丢失
// try { // try {
@ -265,18 +240,105 @@ public class InformationCollector implements XMLReadable, XMLWriter {
// } // }
} }
private boolean sendFunctionRecord(String url, Map<String,Object> record) { private void queryAndSendOnePageFunctionContent(long current, long last, int page) {
QueryCondition condition = QueryFactory.create()
.skip(page * PAGE_SIZE)
.count(PAGE_SIZE)
.addSort(COLUMN_TIME, true)
.addRestriction(RestrictionFactory.lte(COLUMN_TIME, current))
.addRestriction(RestrictionFactory.gte(COLUMN_TIME, last));
try {
DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition);
//第一次查询获取总记录数
if(page == 0){
totalCount = focusPoints.getTotalCount();
}
sendThisPageFunctionContent(focusPoints);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private void sendThisPageFunctionContent(DataList<FocusPoint> focusPoints) {
String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD);
try {
JSONObject jsonObject = dealWithSendFunctionContent(focusPoints);
sendFunctionRecord(url, jsonObject);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private JSONObject dealWithSendFunctionContent(DataList<FocusPoint> focusPoints) throws JSONException {
JSONObject jsonObject = new JSONObject();
Map<String, Object> map = new HashMap<>();
if(!focusPoints.isEmpty()){
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
String bbsUserName = MarketConfig.getInstance().getBbsUsername();
String uuid = envManager.getUUID();
jsonObject.put(ATTR_UUID, uuid);
jsonObject.put(ATTR_USER_NAME, bbsUserName);
for(FocusPoint focusPoint : focusPoints.getList()) {
FunctionRecord functionRecord = getOneRecord(focusPoint);
if (map.containsKey(focusPoint.getId())) {
int times = ((FunctionRecord)map.get(focusPoint.getId())).getTimes() + 1;
functionRecord.setTimes(times);
map.put(focusPoint.getId(), functionRecord);
} else {
map.put(focusPoint.getId(), functionRecord);
}
}
jsonObject.put(ATTR_ITEMS, mapToJSONArray(map));
}
return jsonObject;
}
private JSONArray mapToJSONArray(Map<String,Object> map) throws JSONException {
JSONArray jsonArray = new JSONArray();
for(String keys : map.keySet()){
FunctionRecord functionRecord = (FunctionRecord)map.get(keys);
JSONObject jo = new JSONObject();
jo.put(ATTR_ID, functionRecord.getId());
jo.put(ATTR_TEXT, functionRecord.getText());
jo.put(ATTR_SOURCE, functionRecord.getSource());
jo.put(ATTR_TIME, functionRecord.getTime());
jo.put(ATTR_TITLE, functionRecord.getTitle());
jo.put(ATTR_TIMES, functionRecord.getTimes());
jsonArray.put(jo);
}
return jsonArray;
}
private void sendFunctionRecord(String url, JSONObject record) {
boolean success = false; boolean success = false;
try { try {
String recordUrl = url+"?token=" + SiteCenterToken.generateToken() + "&content="+URLEncoder.encode(new JSONObject(record).toString(), EncodeConstants.ENCODING_UTF_8); HashMap<String, Object> para = new HashMap<>();
String res = HttpToolbox.get(recordUrl); para.put("token", SiteCenterToken.generateToken());
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); para.put("content", record);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
if (success) {
this.lastTime = dateToString();
} else {
FineLoggerFactory.getLogger().error("Error occured when sent function records to the cloud center.");
}
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return success;
} }
private FunctionRecord getOneRecord(FocusPoint focusPoint) {
FunctionRecord functionRecord = new FunctionRecord();
functionRecord.setId(focusPoint.getId() == null?StringUtils.EMPTY : focusPoint.getId());
functionRecord.setText(focusPoint.getText() == null?StringUtils.EMPTY : focusPoint.getText());
functionRecord.setSource(focusPoint.getSource());
functionRecord.setTime(focusPoint.getTime().getTime());
functionRecord.setTitle(focusPoint.getTitle() == null?StringUtils.EMPTY : focusPoint.getTitle());
functionRecord.setUsername(MarketConfig.getInstance().getBbsUsername() == null?StringUtils.EMPTY : MarketConfig.getInstance().getBbsUsername());
functionRecord.setUuid(DesignerEnvManager.getEnvManager().getUUID() == null?StringUtils.EMPTY : DesignerEnvManager.getEnvManager().getUUID());
return functionRecord;
}
/** /**
* 收集开始使用时间发送信息 * 收集开始使用时间发送信息
*/ */
@ -437,35 +499,6 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}); });
} }
public static ArrayList getFunctionsContent(Date current, Date last){
ArrayList<Map<String,Object>> records = new ArrayList<Map<String,Object>>();
QueryCondition condition = QueryFactory.create()
.addRestriction(RestrictionFactory.lte(COLUMN_TIME, current))
.addRestriction(RestrictionFactory.gte(COLUMN_TIME, last));
try {
DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
String bbsUserName = MarketConfig.getInstance().getBbsUsername();
String uuid = envManager.getUUID();
if(!focusPoints.isEmpty()){
for(FocusPoint focusPoint : focusPoints.getList()){
Map<String,Object> record = new HashMap<>();
record.put(ATTR_ID, focusPoint.getId());
record.put(ATTR_TEXT, focusPoint.getText());
record.put(ATTR_SOURCE, focusPoint.getSource());
record.put(ATTR_TIME, focusPoint.getTime().getTime());
record.put(ATTR_TITLE, focusPoint.getTitle());
record.put(ATTR_USER_NAME, bbsUserName);
record.put(ATTR_UUID, uuid);
records.add(record);
}
}
} catch (MetricException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return records;
}
private class StartStopTime implements XMLReadable, XMLWriter { private class StartStopTime implements XMLReadable, XMLWriter {
private String startDate; private String startDate;
@ -505,4 +538,93 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private class FunctionRecord implements Comparable{
private String id;
private String text;
private int source;
private long time;
private int times = 1;
private String title;
private String username;
private String uuid;
public FunctionRecord(){
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getTimes() {
return times;
}
public void setTimes(int times) {
this.times = times;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getSource() {
return source;
}
public void setSource(int source) {
this.source = source;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@Override
public int compareTo(Object o) {
FunctionRecord functionRecord = (FunctionRecord) o;
if(this.getId().equals((functionRecord.getId())) && this.getText().equals(functionRecord.getText())
&& this.getSource() == functionRecord.getSource() && this.getTime() == functionRecord.getTime()
&& this.getTitle().equals(functionRecord.getTitle()) && this.getUsername().equals(functionRecord.getUsername())
&& this.getUuid().equals(functionRecord.getUuid())){
return 0;
}
return 1;
}
}
} }

11
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -204,7 +204,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
} }
@Override @Override
public TemplateProcessInfo getProcessInfo() { public TemplateProcessInfo<WorkBook> getProcessInfo() {
if (processInfo == null) { if (processInfo == null) {
processInfo = new JWorkBookProcessInfo(template); processInfo = new JWorkBookProcessInfo(template);
} }
@ -309,10 +309,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
centerPane.setUpPaneHeight(hasParameterPane() ? parameterPane.getPreferredSize().height : 0); centerPane.setUpPaneHeight(hasParameterPane() ? parameterPane.getPreferredSize().height : 0);
} }
@Override
/** /**
* *
*/ */
@Override
public void setComposite() { public void setComposite() {
super.setComposite(); super.setComposite();
reportComposite.setComponents(); reportComposite.setComponents();
@ -544,10 +544,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
// //////////////////////OLD BELOW///////////////////////// // //////////////////////OLD BELOW/////////////////////////
// //////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////
@Override
/** /**
* set target * set target
*/ */
@Override
public void setTarget(WorkBook book) { public void setTarget(WorkBook book) {
if (book == null) { if (book == null) {
return; return;
@ -1098,7 +1099,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
FILE newFile = createNewEmptyFile(); FILE newFile = createNewEmptyFile();
//如果文件已经打开, 那么就覆盖关闭掉他 //如果文件已经打开, 那么就覆盖关闭掉他
MutilTempalteTabPane.getInstance().closeFileTemplate(newFile); MutilTempalteTabPane.getInstance().closeFileTemplate(newFile);
final TemplateWorkBook tpl = this.getTarget(); final WorkBook tpl = this.getTarget();
// 弹出输入参数 // 弹出输入参数
java.util.Map<String, Object> parameterMap = inputParameters(tpl); java.util.Map<String, Object> parameterMap = inputParameters(tpl);
@ -1106,7 +1107,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath()); String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath());
FileOutputStream fileOutputStream = new FileOutputStream(fullPath); FileOutputStream fileOutputStream = new FileOutputStream(fullPath);
EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter(); EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter();
exporter.export(fileOutputStream, (WorkBook) tpl, parameterMap); exporter.export(fileOutputStream, tpl, parameterMap);
} catch (Exception e1) { } catch (Exception e1) {
FRContext.getLogger().error(e1.getMessage()); FRContext.getLogger().error(e1.getMessage());
} }

6
designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java

@ -335,7 +335,8 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
checkButton(showCount < widthArray.length); checkButton(showCount < widthArray.length);
// richie:当linearray不为空时,说明有了鼠标拖动,下面画由于鼠标拖动产生的效果. // richie:当linearray不为空时,说明有了鼠标拖动,下面画由于鼠标拖动产生的效果.
if (!lineArray.isEmpty()) { //REPORT-13572 点击切换会出现重影,保证:此时鼠标点击是没有放开的,才会绘制轨迹
if (!lineArray.isEmpty() && !isReleased) {
paintDragTab(g2d, textHeight, charWidth, textAscent); paintDragTab(g2d, textHeight, charWidth, textAscent);
} }
@ -568,6 +569,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
* @param evt 鼠标事件 * @param evt 鼠标事件
*/ */
public void mousePressed(MouseEvent evt) { public void mousePressed(MouseEvent evt) {
isReleased = false;
int reportcount = reportComposite.getEditingWorkBook().getReportCount(); int reportcount = reportComposite.getEditingWorkBook().getReportCount();
if (scrollIndex < 0 || scrollIndex >= reportcount) { if (scrollIndex < 0 || scrollIndex >= reportcount) {
return; return;
@ -749,7 +751,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
/** /**
* exchange workSheet * exchange workSheet
* *
* @param workBook * @param
* @param index1 * @param index1
* @param index2 * @param index2
* @return workBook * @return workBook

244
designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java

@ -25,132 +25,134 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
*
* @author zhou * @author zhou
* @since 2012-7-26下午2:03:12 * @since 2012-7-26下午2:03:12
*/ */
public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook> { public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook> {
public WorkBookModelAdapter(JWorkBook jworkbook) { public WorkBookModelAdapter(JWorkBook jworkbook) {
super(jworkbook); super(jworkbook);
} }
@Override
public Parameter[] getParameters() { /**
return this.getBook().getParameters(); * 重命名TableData后的一些操作
} *
* @param oldName 旧名字
// 报表参数 * @param newName 新名字
@Override * @return 返回是否刷新.
public Parameter[] getReportParameters() { */
ReportParameterAttr rpa = this.getBook().getReportParameterAttr(); public boolean renameTableData(String oldName, String newName) {
return rpa == null ? new Parameter[0] : rpa.getParameters(); if (super.renameTableData(oldName, newName)) {
} if (this.getBook().getTableData(oldName) == null) {
jTemplate.refreshParameterPane4TableData(oldName, newName);
// 数据源参数 }
@Override return true;
public Parameter[] getTableDataParameters() { }
TableDataSource source = this.getBook(); return false;
Calculator c = Calculator.createCalculator(); }
c.setAttribute(TableDataSource.KEY, source);
java.util.List<ParameterProvider> list = new java.util.ArrayList<ParameterProvider>(); /**
java.util.Iterator<String> nameIt = this.getBook().getTableDataNameIterator(); * 环境改变.
while (nameIt.hasNext()) { */
TableData td = source.getTableData(nameIt.next()); public void envChanged() {
if (td.getParameters(c) != null) { DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class);
list.addAll(java.util.Arrays.asList(td.getParameters(c))); if (provider != null) {
} provider.refreshToolbar();
} }
return list.toArray(new Parameter[list.size()]); jTemplate.refreshAllNameWidgets();
} }
/** /**
* 重命名TableData后的一些操作 * 参数改变.
* @param oldName 旧名字 */
* @param newName 新名字 public void parameterChanged() {
* @return 返回是否刷新. jTemplate.updateReportParameterAttr();
*/ jTemplate.populateReportParameterAttr();
public boolean renameTableData(String oldName, String newName) { updateCachedParameter();
if (super.renameTableData(oldName, newName)) { }
if (this.getBook().getTableData(oldName) == null) {
jTemplate.refreshParameterPane4TableData(oldName,newName); /**
} * 控件改变.
return true; */
} public void widgetConfigChanged() {
return false; DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class);
} if (provider != null) {
provider.refreshToolbar();
/** }
* 环境改变. jTemplate.refreshAllNameWidgets();
*/ }
public void envChanged() {
DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class); @Override
if (provider != null) { protected Parameter[] getLatestTemplateParameters() {
provider.refreshToolbar(); ReportParameterAttr rpa = this.getBook().getReportParameterAttr();
} return rpa == null ? new Parameter[0] : rpa.getParameters();
jTemplate.refreshAllNameWidgets(); }
}
@Override
/** protected Parameter[] getLatestTableDataParameters() {
* 参数改变. TableDataSource source = this.getBook();
*/ Calculator c = Calculator.createCalculator();
public void parameterChanged() { c.setAttribute(TableDataSource.KEY, source);
jTemplate.updateReportParameterAttr(); java.util.List<ParameterProvider> list = new java.util.ArrayList<ParameterProvider>();
jTemplate.populateReportParameterAttr(); java.util.Iterator<String> nameIt = this.getBook().getTableDataNameIterator();
} while (nameIt.hasNext()) {
TableData td = source.getTableData(nameIt.next());
/** if (td.getParameters(c) != null) {
* 控件改变. list.addAll(java.util.Arrays.asList(td.getParameters(c)));
*/ }
public void widgetConfigChanged() { }
DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class); return list.toArray(new Parameter[list.size()]);
if (provider != null) { }
provider.refreshToolbar();
} @Override
jTemplate.refreshAllNameWidgets(); protected Parameter[] getLatestParameters() {
} return this.getBook().getParameters();
}
/**
* 返回控件的名字 /**
* @return widgetName 控件列表. * 返回控件的名字
*/ *
public List<WidgetName> getWidgetsName() { * @return widgetName 控件列表.
List<WidgetName> list = new ArrayList<WidgetName>(); */
WorkBook wb = this.getBook(); public List<WidgetName> getWidgetsName() {
for (int i = 0, len = wb.getReportCount(); i < len; i++) { List<WidgetName> list = new ArrayList<WidgetName>();
Report report = wb.getReport(i); WorkBook wb = this.getBook();
Iterator it = report.iteratorOfElementCase(); for (int i = 0, len = wb.getReportCount(); i < len; i++) {
while (it.hasNext()) { Report report = wb.getReport(i);
ElementCase ec = (ElementCase)it.next(); Iterator it = report.iteratorOfElementCase();
Iterator cs = ec.cellIterator(); while (it.hasNext()) {
while (cs.hasNext()) { ElementCase ec = (ElementCase) it.next();
CellElement ce = (CellElement)cs.next(); Iterator cs = ec.cellIterator();
if (ce instanceof DefaultTemplateCellElement) { while (cs.hasNext()) {
Widget widget = ((DefaultTemplateCellElement)ce).getWidget(); CellElement ce = (CellElement) cs.next();
if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) { if (ce instanceof DefaultTemplateCellElement) {
list.add(new WidgetName(widget.getWidgetName())); Widget widget = ((DefaultTemplateCellElement) ce).getWidget();
} if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) {
} list.add(new WidgetName(widget.getWidgetName()));
} }
} }
} }
return list; }
} }
return list;
/** }
* 返回悬浮元素的名字数组
* @return 返回数组. /**
*/ * 返回悬浮元素的名字数组
public String[] getFloatNames() { *
TemplateElementCase elementCase = jTemplate.getEditingElementCase(); * @return 返回数组.
*/
List<String> nameList = new ArrayList<String>(); public String[] getFloatNames() {
Iterator<FloatElement> it = elementCase.floatIterator(); TemplateElementCase elementCase = jTemplate.getEditingElementCase();
while (it.hasNext()) {
nameList.add(it.next().getName()); List<String> nameList = new ArrayList<String>();
} Iterator<FloatElement> it = elementCase.floatIterator();
return nameList.toArray(new String[nameList.size()]); while (it.hasNext()) {
} nameList.add(it.next().getName());
}
return nameList.toArray(new String[nameList.size()]);
}
public Widget[] getLinkableWidgets() { public Widget[] getLinkableWidgets() {

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java

@ -53,13 +53,9 @@ public class ActionModel extends AlphaCellModel {
@Override @Override
public JSONObject modelToJson() { public JSONObject modelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { JSONObject modelObject = JSONObject.create();
JSONObject modelObject = JSONObject.create(); modelObject.put("className", getAction().getClass().getName()).put("searchCount", getSearchCount());
modelObject.put("className", getAction().getClass().getName()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return object; return object;
} }

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java

@ -42,13 +42,9 @@ public class DocumentModel extends AlphaCellModel {
@Override @Override
public JSONObject modelToJson() { public JSONObject modelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { JSONObject modelObject = JSONObject.create();
JSONObject modelObject = JSONObject.create(); modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId()).put("searchCount", getSearchCount());
modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FineLoggerFactory.getLogger().error("DocumentModel: " + e.getMessage());
}
return object; return object;
} }

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/FileModel.java

@ -37,13 +37,9 @@ public class FileModel extends AlphaCellModel {
@Override @Override
public JSONObject modelToJson() { public JSONObject modelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { JSONObject modelObject = JSONObject.create();
JSONObject modelObject = JSONObject.create(); modelObject.put("filePath", getFilePath()).put("searchCount", getSearchCount());
modelObject.put("filePath", getFilePath()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return object; return object;
} }

11
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -87,14 +87,9 @@ public class PluginModel extends AlphaCellModel {
@Override @Override
public JSONObject modelToJson() { public JSONObject modelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { JSONObject modelObject = JSONObject.create();
JSONObject modelObject = JSONObject.create(); modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("id", getId()).put("pluginid", getPluginId()).put("type", getType().getTypeValue()).put("price", getPrice()).put("link", getLink()).put("searchCount", getSearchCount());
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("id", getId()).put("pluginid", getPluginId()).put("type", getType().getTypeValue()).put("price", getPrice()).put("link", getLink()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return object; return object;
} }

12
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java

@ -55,7 +55,7 @@ public class RobotModel extends AlphaCellModel {
} }
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
return jsonObject.optString("msg"); return jsonObject.optString("msg");
} catch (JSONException | IOException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error("get robotmodel content error: " + e.getMessage()); FineLoggerFactory.getLogger().error("get robotmodel content error: " + e.getMessage());
} }
return null; return null;
@ -69,13 +69,9 @@ public class RobotModel extends AlphaCellModel {
@Override @Override
public JSONObject modelToJson() throws JSONException { public JSONObject modelToJson() throws JSONException {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { JSONObject modelObject = JSONObject.create();
JSONObject modelObject = JSONObject.create(); modelObject.put("title", getTitle()).put("content", getContent()).put("searchCount", getSearchCount());
modelObject.put("title", getTitle()).put("content", getContent()).put("searchCount", getSearchCount()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FineLoggerFactory.getLogger().error("RobotModel: " + e.getMessage());
}
return object; return object;
} }

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -976,11 +976,7 @@ public class AlphaFineDialog extends UIDialog {
int resultKind = cellModel.getType().getTypeValue(); int resultKind = cellModel.getType().getTypeValue();
String resultValue = CellModelHelper.getResultValueFromModel(cellModel); String resultValue = CellModelHelper.getResultValueFromModel(cellModel);
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { object.put("uuid", uuid).put("activityKey", activityKey).put("username", username).put("createTime", createTime).put("key", key).put("resultKind", resultKind).put("resultValue", resultValue);
object.put("uuid", uuid).put("activityKey", activityKey).put("username", username).put("createTime", createTime).put("key", key).put("resultKind", resultKind).put("resultValue", resultValue);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
final HashMap<String, String> para = new HashMap<>(); final HashMap<String, String> para = new HashMap<>();
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
para.put("token", CodeUtils.md5Encode(date, StringUtils.EMPTY, "MD5")); para.put("token", CodeUtils.md5Encode(date, StringUtils.EMPTY, "MD5"));

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java

@ -81,10 +81,8 @@ public class DocumentSearchManager implements AlphaFineSearchProvider {
} }
} }
} }
} catch (JSONException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error("document search error: " + e.getMessage()); FineLoggerFactory.getLogger().error("document search error: " + e.getMessage());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("document search get result error: " + e.getMessage());
} }
} }
lessModelList.clear(); lessModelList.clear();

8
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -126,12 +126,8 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
} }
} }
} }
} catch (JSONException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error("plugin search json error :" + e.getMessage()); FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage());
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().error("plugin search encode error :" + e.getMessage());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("plugin search get result error :" + e.getMessage());
} }
} }
if (searchResult.isEmpty()) { if (searchResult.isEmpty()) {

18
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java

@ -100,17 +100,13 @@ public class ErrorInfo {
*/ */
public void saveAsJSON(){ public void saveAsJSON(){
JSONObject jo = JSONObject.create(); JSONObject jo = JSONObject.create();
try { jo.put("username", username);
jo.put("username", username); jo.put("uuid", uuid);
jo.put("uuid", uuid); jo.put("activekey", activekey);
jo.put("activekey", activekey); jo.put("templateid", templateid);
jo.put("templateid", templateid); jo.put("uploadtime", uploadtime);
jo.put("uploadtime", uploadtime); jo.put("logid", logid);
jo.put("logid", logid); jo.put("log", log);
jo.put("log", log);
} catch (JSONException ignore) {
}
saveFileToCache(jo); saveFileToCache(jo);
} }

82
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

@ -3,15 +3,16 @@ package com.fr.design.mainframe.errorinfo;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.mainframe.SiteCenterToken; import com.fr.design.mainframe.SiteCenterToken;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpResponseType;
import com.fr.json.JSONException; import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler; import com.fr.log.LogHandler;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -93,9 +94,7 @@ public class ErrorInfoUploader {
try { try {
String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution"); String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution");
downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken()); downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken());
HttpClient hc = new HttpClient(downloadURL); InputStream in = HttpToolbox.post(downloadURL, new HashMap<String, Object>(), HttpResponseType.STREAM);
hc.asGet();
InputStream in = hc.getResponseStream();
StableUtils.makesureFileExist(localCacheZip); StableUtils.makesureFileExist(localCacheZip);
FileOutputStream out = new FileOutputStream(localCacheZip); FileOutputStream out = new FileOutputStream(localCacheZip);
IOUtils.copyBinaryTo(in, out); IOUtils.copyBinaryTo(in, out);
@ -114,15 +113,11 @@ public class ErrorInfoUploader {
// 判断本地文件大小. // 判断本地文件大小.
String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check"); String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check");
checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken()); checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken());
HttpClient client = new HttpClient(checkURL); try {
client.asGet(); JSONObject res = new JSONObject(HttpToolbox.get(checkURL));
if (client.isServerAlive()) { // 简单粗暴, 直接判断文件大小.
try { return res.optLong("version") != localCacheZip.length();
JSONObject res = new JSONObject(client.getResponseText()); } catch (Exception ignore) {
// 简单粗暴, 直接判断文件大小.
return res.optLong("version") != localCacheZip.length();
} catch (JSONException ignore) {
}
} }
return false; return false;
} }
@ -140,27 +135,29 @@ public class ErrorInfoUploader {
} }
File[] files = folder.listFiles(); File[] files = folder.listFiles();
if (files.length > MAX_ERROR_SIZE) { if (ArrayUtils.getLength(files) > MAX_ERROR_SIZE) {
StableUtils.deleteFile(folder); CommonIOUtils.deleteFile(folder);
return; return;
} }
try { try {
for (File file : files) { if (ArrayUtils.isNotEmpty(files)) {
String filePath = file.getPath(); for (File file : files) {
String suffix = filePath.substring(filePath.lastIndexOf(".")); String filePath = file.getPath();
String suffix = filePath.substring(filePath.lastIndexOf("."));
if (suffix.endsWith(SUFFIX)) {
Thread.sleep(1000L); if (suffix.endsWith(SUFFIX)) {
String content = IOUtils.inputStream2String(new FileInputStream(file)); Thread.sleep(1000L);
if (content.length() > MAX_ERROR_SIZE) { String content = IOUtils.inputStream2String(new FileInputStream(file));
file.delete(); if (content.length() > MAX_ERROR_SIZE) {
continue; CommonIOUtils.deleteFile(file);
} continue;
}
String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
if (sendErroInfo(url, content)) { String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
file.delete(); if (sendErrorInfo(url, content)) {
CommonIOUtils.deleteFile(file);
}
} }
} }
} }
@ -169,25 +166,18 @@ public class ErrorInfoUploader {
} }
} }
private boolean sendErroInfo(String url, String content) { private boolean sendErrorInfo(String url, String content) {
HashMap<String, String> para = new HashMap<>(); HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken()); para.put("token", SiteCenterToken.generateToken());
para.put("content", content); para.put("content", content);
HttpClient httpClient = new HttpClient(url, para, true);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return false;
}
String res = httpClient.getResponseText();
boolean success;
try { try {
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); String responseText = HttpToolbox.post(url, para);
} catch (Exception ex) { return "success".equals(new JSONObject(responseText).get("status"));
success = true; } catch (Exception ignore) {
} }
return success; return false;
} }

16
designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java

@ -2,6 +2,7 @@ package com.fr.design.present;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.config.StyleMap;
import com.fr.design.gui.controlpane.AbstractNameableCreator; import com.fr.design.gui.controlpane.AbstractNameableCreator;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
@ -13,6 +14,8 @@ import com.fr.design.style.StylePane;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerAdaptor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -90,17 +93,16 @@ public class StyleArrayPane extends JListControlPane {
/** /**
* Update. * Update.
*/ */
public void update(ServerPreferenceConfig configManager) { public void update(final ServerPreferenceConfig configManager) {
configManager.clearAllStyle(); //configManager.clearAllStyle();
// Nameable[]居然不能强转成Parameter[],一定要这么写... // Nameable[]居然不能强转成Parameter[],一定要这么写...
Nameable[] nameables = this.update(); Nameable[] nameables = this.update();
final StyleMap styleMap = new StyleMap();
for (int i = 0; i < nameables.length; i++) { for (int i = 0; i < nameables.length; i++) {
configManager.putStyle(((NameObject)nameables[i]).getName(), (Style)((NameObject)nameables[i]).getObject()); styleMap.put(((NameObject)nameables[i]).getName(), (Style)((NameObject)nameables[i]).getObject());
} }
DesignerContext.getDesignerBean("predefinedStyle").refreshBeanElement();
}
configManager.setStyleMap(styleMap);
}
} }

2
designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java

@ -373,7 +373,7 @@ public abstract class AbstractNativePrintSettingPane extends JPanel {
{customPageRadioButton, specifiedAreaField, areaFieldTip}, {customPageRadioButton, specifiedAreaField, areaFieldTip},
{doublePrintRadioButton, doublePrintComboBox, new JPanel()} {doublePrintRadioButton, doublePrintComboBox, new JPanel()}
}; };
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 8);
} }
private JPanel getScalePane() { private JPanel getScalePane() {

4
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -508,6 +508,10 @@ public class CellSelection extends Selection {
popup.add(DeprecatedActionManager.getInsertMenu(ePane)); popup.add(DeprecatedActionManager.getInsertMenu(ePane));
popup.add(DeprecatedActionManager.getDeleteMenu(ePane)); popup.add(DeprecatedActionManager.getDeleteMenu(ePane));
popup.add(DeprecatedActionManager.getClearMenu(ePane)); popup.add(DeprecatedActionManager.getClearMenu(ePane));
popup.addSeparator();
addExtraMenu(ePane, popup);
return popup; return popup;
} }

6
designer-realize/src/main/java/com/fr/grid/selection/FloatSelection.java

@ -1,6 +1,5 @@
package com.fr.grid.selection; package com.fr.grid.selection;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.cell.CleanAuthorityAction; import com.fr.design.actions.cell.CleanAuthorityAction;
@ -27,7 +26,6 @@ import com.fr.design.mainframe.ElementCasePane.Clear;
import com.fr.design.selection.QuickEditor; import com.fr.design.selection.QuickEditor;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
@ -149,6 +147,10 @@ public class FloatSelection extends Selection {
popup.add(new EditFloatElementNameAction(ePane).createMenuItem()); popup.add(new EditFloatElementNameAction(ePane).createMenuItem());
popup.addSeparator();
addExtraMenu(ePane, popup);
return popup; return popup;
} }

36
designer-realize/src/main/java/com/fr/grid/selection/Selection.java

@ -1,19 +1,22 @@
package com.fr.grid.selection; package com.fr.grid.selection;
import java.io.Serializable;
import javax.swing.JPopupMenu;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.design.selection.SelectableElement; import com.fr.design.selection.SelectableElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.FCloneable; import com.fr.stable.FCloneable;
import javax.swing.JPopupMenu;
import java.io.Serializable;
import java.util.Set;
/* /*
* TODO ALEX_SEP Selection是跟ElementCasePane绑定的,能不能把ElementCasePane保存在Selection里面呢? * TODO ALEX_SEP Selection是跟ElementCasePane绑定的,能不能把ElementCasePane保存在Selection里面呢?
* *
@ -24,10 +27,8 @@ import com.fr.stable.FCloneable;
public abstract class Selection implements FCloneable, Serializable , SelectableElement { public abstract class Selection implements FCloneable, Serializable , SelectableElement {
public abstract boolean isSelectedOneCell(ElementCasePane ePane); public abstract boolean isSelectedOneCell(ElementCasePane ePane);
// ///////////////////////////////copy/////////////////////////////////
public abstract void asTransferable(ElementsTransferable transferable, ElementCasePane ePane); public abstract void asTransferable(ElementsTransferable transferable, ElementCasePane ePane);
// ///////////////////////////////paste////////////////////////////////
public boolean pasteFloatElementClip(FloatElementsClip feClip, ElementCasePane ePane) { public boolean pasteFloatElementClip(FloatElementsClip feClip, ElementCasePane ePane) {
FloatElementsClip floatElementClip; FloatElementsClip floatElementClip;
try { try {
@ -53,7 +54,6 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
public abstract boolean pasteOtherType(Object ob, ElementCasePane ePane); public abstract boolean pasteOtherType(Object ob, ElementCasePane ePane);
// ///////////////////////////////merge////////////////////////////////
public abstract boolean canMergeCells(ElementCasePane ePane); public abstract boolean canMergeCells(ElementCasePane ePane);
public abstract boolean mergeCells(ElementCasePane ePane); public abstract boolean mergeCells(ElementCasePane ePane);
@ -62,18 +62,28 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
public abstract boolean unMergeCells(ElementCasePane ePane); public abstract boolean unMergeCells(ElementCasePane ePane);
// ///////////////////////////////popup////////////////////////////////
public abstract JPopupMenu createPopupMenu(ElementCasePane ePane); public abstract JPopupMenu createPopupMenu(ElementCasePane ePane);
// ///////////////////////////////clear//////////////////////////////// /**
* 添加插件菜单(增删改都可以)
* @param ePane
* @param popupMenu
*/
public void addExtraMenu(ElementCasePane ePane, UIPopupMenu popupMenu) {
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) {
handler.dmlMenu(ePane, popupMenu);
}
}
}
public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane); public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane);
// ////////////////////////////////////////////////////////////////////
public abstract int[] getSelectedRows(); public abstract int[] getSelectedRows();
public abstract int[] getSelectedColumns(); public abstract int[] getSelectedColumns();
// //////////////////////////////move//////////////////////////////////
public abstract void moveLeft(ElementCasePane ePane); public abstract void moveLeft(ElementCasePane ePane);
public abstract void moveRight(ElementCasePane ePane); public abstract void moveRight(ElementCasePane ePane);
@ -82,10 +92,8 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
public abstract void moveDown(ElementCasePane ePane); public abstract void moveDown(ElementCasePane ePane);
// //////////////////////////DeleteAction///////////////////////////////
public abstract boolean triggerDeleteAction(ElementCasePane ePane); public abstract boolean triggerDeleteAction(ElementCasePane ePane);
// //////////////////////////Just4CellSelection///////////////////////////////
public abstract boolean containsColumnRow(ColumnRow cr); public abstract boolean containsColumnRow(ColumnRow cr);
public abstract void populatePropertyPane(ElementCasePane ePane); public abstract void populatePropertyPane(ElementCasePane ePane);

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

Loading…
Cancel
Save