Browse Source

Merge pull request #704 in DESIGN/design from ~JEO/report-design:final/10.0 to final/10.0

* commit '044d7515b1d6ac65430a0ba57392de39dd1716cc': (60 commits)
  REPORT-13074 远程设计向下兼容 1. 将尝试连接和正式连接提示分开。
  REPORT-13431 功能点记录, 需要合并发送 1.发送前去重 2.SEND_DELAY原先定义有误,修正
  REPORT-13074 远程设计向下兼容 1. 忘了注释掉
  REPORT-13074 远程设计向下兼容 1. 修复一下逻辑。 更方便理解
  REPORT-13074 远程设计向下兼容 1. 补充一些注释。
  REPORT-13074 远程设计向下兼容 1. 加入序列化异常 SerilizationException , WorkspaceNoteHitException 2. 加入切换远程连接的检测,以及测试远程连接的提醒。
  MOBILE-18801
  CHART-3575 修改为需要的'分类名'
  CHART-3573 使用新的key来区别开'空值断开'
  CHART-3169 新特性图表 样式系列颜色风格 改为'渐变'
  REPORT-13689 & REPORT-13733 & REPORT-13716 & REPORT-13720
  REPORT-13018 大赛后续开两个接口
  REPORT-13717 打开不同工作目录下的同名模板
  REPORT-10829 开发者大赛支撑,接口同步10.0 ,有遗漏
  REPORT-13654 测试系统换上12号的release后,调色板出不来了
  MOBILE-18837【RN】表单》tabpane》移动端样式模板设为默认,tabpane一些字体属性不生效
  REPORT-13528 最新的jar,图片超链不能取到组件
  整理代码
  真正成因: XNameWidegt漏加setEnable
  REPORT-13614 【10.0.2回归】预定义控件设置不可用失效
  ...
final/10.0
Kara 6 years ago
parent
commit
758609ac27
  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. 57
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 60
      designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java
  5. 38
      designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java
  6. 26
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  7. 8
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JNDIDefPane.java
  8. 5
      designer-base/src/main/java/com/fr/design/designer/TargetComponent.java
  9. 83
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  10. 4
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  11. 120
      designer-base/src/main/java/com/fr/design/extra/ucenter/AbstractClient.java
  12. 264
      designer-base/src/main/java/com/fr/design/extra/ucenter/Client.java
  13. 41
      designer-base/src/main/java/com/fr/design/extra/ucenter/XMLHelper.java
  14. 13
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  15. 5
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  16. 63
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  17. 69
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  18. 327
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  19. 55
      designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java
  20. 45
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractRightSelectionHandlerProvider.java
  21. 16
      designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java
  22. 19
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  23. 4
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  24. 11
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  25. 11
      designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java
  26. 57
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  27. 2
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  28. 33
      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. 7
      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. 34
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  43. 62
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java
  44. 76
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java
  45. 8
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/FormHyperlinkNorthPane.java
  46. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartDatapointLabelPane.java
  47. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/CustomDefaultSeriesPane.java
  48. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/CustomTypeConditionSeriesPane.java
  49. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/LineSeriesPane.java
  50. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/RadarSeriesPane.java
  51. 5
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java
  52. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  53. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/format/CategoryNameFormatPaneWithCheckBox.java
  54. 2
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java
  55. 16
      designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java
  56. 66
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  57. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  58. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java
  59. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  60. 8
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  61. 30
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  62. 35
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  63. 187
      designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java
  64. 58
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java
  65. 11
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  66. 11
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  67. 5
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  68. 22
      designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java
  69. 77
      designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java
  70. 48
      designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java
  71. 2
      designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java
  72. 3
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  73. 225
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  74. 11
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  75. 6
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  76. 244
      designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java
  77. 16
      designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java
  78. 4
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  79. 6
      designer-realize/src/main/java/com/fr/grid/selection/FloatSelection.java
  80. 36
      designer-realize/src/main/java/com/fr/grid/selection/Selection.java
  81. 4
      designer-realize/src/main/java/com/fr/start/Designer.java
  82. 2
      designer-realize/src/main/java/com/fr/start/SplashContext.java

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.io.BaseBook;
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.JTemplateProvider;
import com.fr.form.ui.Widget;
@ -14,68 +16,159 @@ import java.util.List;
import java.util.Map;
/**
* 当前的设计器模式
* 设计器模式 FormModel or WorkBookModel
* <p>
* 指的是编辑的模板是普通报表还是决策报表
*
* @author zhou
* @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;
/**
* 模板
*/
protected S jTemplate;
/**
* 全部的参数包括全局参数模板参数和数据集参数
*/
private Parameter[] parameters;
/**
* 数据集参数
*/
private Parameter[] tableDataParameters;
/**
* 模板参数
*/
private Parameter[] templateParameters;
public DesignModelAdapter(S 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() {
return jTemplate;
}
/**
* 设置当前编辑的模板
* 不要脱离上下文直接调用
*
* @param jTemplate jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
* @deprecated use {@link HistoryTemplateListCache#setCurrentEditingTemplate(JTemplate)} instead
*/
@Deprecated
public void setjTemplate(S jTemplate) {
this.jTemplate = jTemplate;
}
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() {
((JTemplate) this.jTemplate).fireTargetModified();
this.jTemplate.fireTargetModified();
}
/**
* 获取悬浮元素名称数组
*
* @return String[] 悬浮元素名称数组
*/
public String[] getFloatNames() {
return new String[0];
}
/**
* 获取编辑模板的所有参数
* <p>
* 由于在参数面板拖动过程中频繁获取
* 远程设计时数据集参数rpc 调用需要考虑网络等因素,因此会比较缓慢,引起参数面板拖动卡顿,
* 所以缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板的所有参数
*/
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() {
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() {
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;
}
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
return renameTableData(oldName, newName, true);
}
/**
* 重命名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 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();
/**
* 获取变更后的模板参数
*/
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 boolean supportCellEditorDef = false;
private boolean isDragPermited = false;
private Locale language = Locale.SIMPLIFIED_CHINESE;
private Locale language = Locale.getDefault();
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;

57
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.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
@ -15,19 +16,25 @@ import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
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.SwingUtilities;
import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance {
@ -90,6 +97,12 @@ public class EnvChangeEntrance {
});
return false;
}
// 如果版本不一致,且确认 不继续 连接,这里返回 false.
if (!versionCheckAndConfirm(selectedEnv)) {
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
@ -138,6 +151,50 @@ public class EnvChangeEntrance {
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
*

60
designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java

@ -1,14 +1,8 @@
package com.fr.design.bbs;
import com.fr.config.BBSAttr;
import com.fr.config.Configuration;
import com.fr.config.MarketConfig;
import com.fr.base.passport.FinePassportManager;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import java.util.List;
/**
* Created by ibm on 2017/8/21.
@ -16,62 +10,14 @@ import java.util.List;
public class BBSLoginUtils {
public static void bbsLogin(final String username, final String password) {
final BBSAttr bbsAttr = new BBSAttr();
bbsAttr.setBbsUsername(username);
bbsAttr.setBbsPassword(password);
try {
Configurations.update(new Worker() {
@Override
public void run() {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{MarketConfig.class};
}
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public static void bbsLogin(List<String> list) {
try {
String uid = list.get(0);
String username = list.get(1);
String password = list.get(2);
final BBSAttr bbsAttr = new BBSAttr();
bbsAttr.setBbsUsername(username);
bbsAttr.setBbsPassword(password);
bbsAttr.setBbsUid(Integer.parseInt(uid));
bbsAttr.setInShowBBsName(username);
Configurations.update(new Worker() {
@Override
public void run() {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{MarketConfig.class};
}
});
FinePassportManager.getInstance().login(username, password);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public static void bbsLogout() {
final BBSAttr bbsAttr = new BBSAttr();
bbsAttr.setBbsUsername(StringUtils.EMPTY);
bbsAttr.setBbsPassword(StringUtils.EMPTY);
bbsAttr.setBbsUid(0);
bbsAttr.setInShowBBsName(StringUtils.EMPTY);
try {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
FinePassportManager.getInstance().logout();
}
}

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

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.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
@ -36,8 +37,8 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private JDialog dialog;
private UILabel uiLabel;
// 编码转换.
private UIComboBox newCharSetComboBox;
private String oirginalCharSet = null;
private UIComboBox charSetComboBox;
private String originalCharSet = null;
// Database pane
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"));
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")};
newCharSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH);
@ -72,7 +73,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
new ModLineBorder(ModLineBorder.TOP),
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();
@ -81,8 +82,12 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override
public void populateBean(com.fr.data.impl.Connection ob) {
this.oirginalCharSet = ob.getOriginalCharsetName();
this.newCharSetComboBox.setSelectedItem(ob.getNewCharsetName());
this.originalCharSet = ob.getOriginalCharsetName();
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);
}
@ -93,11 +98,14 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public com.fr.data.impl.Connection updateBean() {
E ob = updateSubDatabaseConnectionBean();
ob.setOriginalCharsetName(this.oirginalCharSet);
if (this.newCharSetComboBox.getSelectedIndex() == 0) {
ob.setOriginalCharsetName(this.originalCharSet);
if (this.charSetComboBox.getSelectedIndex() == 0) {
ob.setNewCharsetName(null);
ob.setOriginalCharsetName(null);
} else {
ob.setNewCharsetName((String) this.newCharSetComboBox.getSelectedItem());
ob.setNewCharsetName(EncodeConstants.ENCODING_GBK);
ob.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem()));
}
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.
Hashtable<String, String> contextHashtable = jndiDatabase.getContextHashtable();
Map<String, String> contextHashtable = jndiDatabase.getContextHashtable();
Object INITIAL_CONTEXT_FACTORY = contextHashtable.get(Context.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);
}
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);
if (PROVIDER_URL != null) {
textField.setText(PROVIDER_URL);
@ -160,7 +160,7 @@ public class JNDIDefPane extends JPanel {
jndiDatabase.setJNDIName(this.jndiNameTextField.getText());
Hashtable<String, String> contextHashtable = jndiDatabase.getContextHashtable();
Map<String, String> contextHashtable = jndiDatabase.getContextHashtable();
String factoryString = (String)this.JNDIFactoryComboBox.getEditor().getItem();
if (factoryString != null && factoryString.trim().length() > 0) {
@ -186,7 +186,7 @@ public class JNDIDefPane extends JPanel {
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();
if (tValue != null && tValue.trim().length() > 0) {
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.TargetModifiedListener;
import com.fr.design.mainframe.AuthorityEditPane;
import com.fr.design.mainframe.JTemplateProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef;
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;
public TargetComponent(T t) {
@ -34,6 +35,7 @@ public abstract class TargetComponent<T> extends JComponent {
public abstract void stopEditing();
@Override
public T getTarget() {
return target;
}
@ -82,6 +84,7 @@ public abstract class TargetComponent<T> extends JComponent {
/**
* Fire template modified listeners.
*/
@Override
public void fireTargetModified() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();

83
designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java

@ -1,23 +1,18 @@
package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig;
import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.ucenter.Client;
import com.fr.design.extra.ucenter.XMLHelper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javafx.concurrent.Task;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Color;
@ -25,8 +20,6 @@ import java.awt.Desktop;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.util.LinkedList;
import java.util.List;
/**
* @author vito
@ -150,7 +143,7 @@ public class LoginWebBridge {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@ -161,7 +154,7 @@ public class LoginWebBridge {
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.register")));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@ -172,7 +165,7 @@ public class LoginWebBridge {
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset")));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@ -202,35 +195,16 @@ public class LoginWebBridge {
if (!testConnection()) {
return NET_FAILED;
}
List<String> loginResult = frPassport(userInfo, password);
String uid = loginResult.get(0);
String username = loginResult.get(1);
if (Integer.parseInt(uid) > 0) {
loginSuccess(username);
}
return uid;
}
private List<String> frPassport(String username, String password) {
LinkedList<String> list = new LinkedList<>();
int uid = 0;
try {
Client uc = new Client();
String result = uc.ucUserLogin(username, password);
result = new String(result.getBytes("iso-8859-1"), "gbk");
list = XMLHelper.ucUnserialize(result);
if (list.size() > 0) {
int uid = Integer.parseInt(list.get(0));
if (uid > 0) {
BBSLoginUtils.bbsLogin(list);
}
} else {
list.push(NET_FAILED);
}
uid = FinePassportManager.getInstance().login(userInfo, password);
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
list.push(UNKNOWN_ERROR);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (uid > 0) {
loginSuccess(MarketConfig.getInstance().getBbsUsername());
}
return list;
return String.valueOf(uid);
}
/**
@ -276,39 +250,6 @@ public class LoginWebBridge {
}
}
/**
* 获取用户信息
*
* @param userInfo
*/
public void getLoginInfo(String userInfo) {
try {
JSONObject jo = new JSONObject(userInfo);
String status = jo.get("status").toString();
if (ComparatorUtils.equals(status, LOGIN_SUCCESS)) {
String username = jo.get("username").toString();
int uid = Integer.parseInt(jo.get("uid") == null ? StringUtils.EMPTY : jo.get("uid").toString());
closeQQWindow();
loginSuccess(username);
LinkedList<String> list = new LinkedList<>();
list.add(String.valueOf(uid));
list.add(username);
list.add(StringUtils.EMPTY);
BBSLoginUtils.bbsLogin(list);
} else if (ComparatorUtils.equals(status, LOGIN_FAILED)) {
//账号没有QQ授权
closeQQWindow();
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("QQ_binding")));
} catch (Exception ignored) {
// ignored
}
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) {
if (url.indexOf("qqLogin.html") > 0) {

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

@ -1,8 +1,8 @@
package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper;
import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.GetInstalledPluginsExecutor;
import com.fr.design.extra.exe.GetPluginCategoriesExecutor;
@ -554,7 +554,7 @@ public class PluginWebBridge {
*/
public void clearUserInfo() {
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
BBSLoginUtils.bbsLogout();
FinePassportManager.getInstance().logout();
uiLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_UnSignIn"));
}

120
designer-base/src/main/java/com/fr/design/extra/ucenter/AbstractClient.java

@ -1,120 +0,0 @@
package com.fr.design.extra.ucenter;
import com.fr.base.Base64;
import com.fr.base.FRContext;
import com.fr.stable.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
/**
* @author lp
* @date 2016/9/9
*/
public abstract class AbstractClient {
static final String UC_API_MYSQL = "ucApiMysql";
static final String UC_API_POST = "ucApiPost";
protected String urlEncode(String value) {
return URLEncoder.encode(value);
}
protected String md5(String input) {
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
return byte2hex(md.digest(input.getBytes()));
}
protected String md5(long input) {
return md5(String.valueOf(input));
}
protected String base64Decode(String input) {
try {
return new String(Base64.decode(input));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
}
protected String base64Encode(String input) {
try {
return Base64.encode(input.getBytes("iso-8859-1"));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
}
protected String byte2hex(byte[] b) {
StringBuilder hs = new StringBuilder();
String stmp = "";
for (byte aB : b) {
stmp = (Integer.toHexString(aB & 0XFF));
if (stmp.length() == 1) {
hs.append("0").append(stmp);
} else {
hs.append(stmp);
}
}
return hs.toString();
}
protected String subStr(String input, int begin, int length) {
return input.substring(begin, begin + length);
}
protected String subStr(String input, int begin) {
if (begin > 0) {
return input.substring(begin);
} else {
return input.substring(input.length() + begin);
}
}
protected long microTime() {
return System.currentTimeMillis();
}
protected long time() {
return System.currentTimeMillis() / 1000;
}
protected String sprintf(String format, long input) {
String temp = "0000000000" + input;
return temp.substring(temp.length() - 10);
}
protected String callUserFunc(String function, String model, String action, Map<String, Object> args) {
if (UC_API_MYSQL.equals(function)) {
return this.ucApiMysql(model, action, args);
}
if (UC_API_POST.equals(function)) {
return this.ucApiPost(model, action, args);
}
return StringUtils.EMPTY;
}
public abstract String ucApiPost(String module, String action, Map<String, Object> arg);
public abstract String ucApiMysql(String model, String action, Map args);
protected String urlEncode(String value, String code) {
try {
return URLEncoder.encode(value, code);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().info(e.getMessage());
}
return "";
}
}

264
designer-base/src/main/java/com/fr/design/extra/ucenter/Client.java

@ -1,264 +0,0 @@
package com.fr.design.extra.ucenter;
import com.fr.base.FRContext;
import com.fr.general.CloudCenter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
*
* @author lp
* @date 2016/9/9
*/
public class Client extends AbstractClient {
private static String UC_IP = "";
private static String UC_API = "";
private static String UC_CONNECT = "";
private static String UC_KEY = "Rc85U37411p4zdvcedm8D4t4D3l9Sa42H0kd98Gbd82aA99a61S2Z5LbQ9u430M0";
private static String UC_APPID = "4";
private static String UC_CLIENT_RELEASE = "20090212";
public static String UC_ROOT = "";
private static String UC_API_FUNC = "mysql".equals(UC_CONNECT) ? UC_API_MYSQL : UC_API_POST;
public String ucUserLogin(String username, String password) {
return ucUserLogin(username, password, 0, 0);
}
public String ucUserLogin(String username, String password, int isUid, int checkQues) {
return ucUserLogin(username, password, isUid, checkQues, "", "");
}
/**
* 用户登录
*
* @param username 用户名
* @param password 密码
* @param isUid 是否为uid
* @param checkQues 是否使用安全问题
* @param questionId 安全提问
* @param answer 安全提问答案
* @return array (uid/status, username, password, email)
*/
public String ucUserLogin(String username, String password, int isUid, int checkQues, String questionId, String answer) {
Map<String, Object> args = new HashMap<>(6);
args.put("username", username);
args.put("password", password);
args.put("isUid", isUid);
args.put("checkQues", checkQues);
args.put("questionId", questionId);
args.put("answer", answer);
String res = callUserFunc(UC_API_FUNC, "user", "login", args);
return "mysql".equals(UC_CONNECT) ? res : res;
}
/**
* 拼接发送的post请求
*
* @param module 模块
* @param action 操作模式
* @param arg 参数
* @return 发送的请求加密内容
*/
@Override
public String ucApiPost(String module, String action, Map<String, Object> arg) {
StringBuilder str = new StringBuilder();
String sep = "";
for (String k : arg.keySet()) {
Object v = arg.get(k);
k = urlEncode(k);
if (v.getClass().isAssignableFrom(Map.class)) {
StringBuilder s2 = new StringBuilder();
String sep2 = "";
for (String k2 : ((Map<String, Object>) v).keySet()) {
Object v2 = ((Map<String, Object>) v).get(k2);
k2 = urlEncode(k2);
s2.append(sep2).append("{").append(k).append("}[").append(k2).append("]=").append(urlEncode(String.valueOf(v2)));
sep2 = "&";
}
str.append(sep).append(s2);
} else {
str.append(sep).append(k).append("=").append(urlEncode(String.valueOf(v), "GBK"));
}
sep = "&";
}
String postData = ucApiRequestdata(module, action, str.toString(), "");
UC_API = CloudCenter.getInstance().acquireUrlByKind("bbs.ucapi");
UC_IP = CloudCenter.getInstance().acquireUrlByKind("bbs.ip");
return ucFopen2(UC_API + "/index.php", 500000, postData, "", true, UC_IP, 20, true);
}
@Override
public String ucApiMysql(String model, String action, Map args) {
return "";
}
public String ucApiInput(String data) {
return urlEncode(ucAuthCode(data + "&agent=" + md5("") + "&time=" + time(), "ENCODE", UC_KEY), "GBK");
}
protected String ucApiRequestdata(String module, String action, String arg, String extra) {
String input = ucApiInput(arg);
return "m=" + module + "&a=" + action + "&inajax=2&release=" + UC_CLIENT_RELEASE + "&input=" + input + "&appid=" + UC_APPID + extra;
}
public String ucAuthCode(String string, String operation, String key) {
return ucAuthCode(string, operation, key, 0);
}
/**
* 内容加密
*
* @param string 原文
* @param operation decode或者encode
* @param key 密钥
* @param expiry 密文有效时限
* @return 加密之后的原文
*/
public String ucAuthCode(String string, String operation, String key, int expiry) {
int ckeyLength = 4;
key = md5(key != null ? key : UC_KEY);
String keya = md5(subStr(key, 0, 16));
String keyb = md5(subStr(key, 16, 16));
String keyc = "DECODE".equals(operation) ? subStr(string, 0, ckeyLength) : subStr(md5(microTime()), -ckeyLength);
String cryptkey = keya + md5(keya + keyc);
int keyLength = cryptkey.length();
string = "DECODE".equals(operation) ? base64Decode(subStr(string, ckeyLength)) : sprintf("%010d", expiry > 0 ? expiry + time() : 0) + subStr(md5(string + keyb), 0, 16) + string;
int stringLength = string.length();
StringBuilder result1 = new StringBuilder();
int[] box = new int[256];
for (int i = 0; i < 256; i++) {
box[i] = i;
}
int[] rndkey = new int[256];
for (int i = 0; i <= 255; i++) {
rndkey[i] = (int) cryptkey.charAt(i % keyLength);
}
int j = 0;
for (int i = 0; i < 256; i++) {
j = (j + box[i] + rndkey[i]) % 256;
int tmp = box[i];
box[i] = box[j];
box[j] = tmp;
}
j = 0;
int a = 0;
for (int i = 0; i < stringLength; i++) {
a = (a + 1) % 256;
j = (j + box[a]) % 256;
int tmp = box[a];
box[a] = box[j];
box[j] = tmp;
result1.append((char) (((int) string.charAt(i)) ^ (box[(box[a] + box[j]) % 256])));
}
if ("DECODE".equals(operation)) {
String result = result1.toString();
try {
result = new String(result.getBytes("iso-8859-1"), "gbk");
} catch (Exception e) {
result = result1.substring(0, result1.length());
}
if ((Integer.parseInt(subStr(result, 0, 10)) == 0 || Long.parseLong(subStr(result, 0, 10)) - time() > 0) && subStr(result, 10, 16).equals(subStr(md5(subStr(result, 26) + keyb), 0, 16))) {
return subStr(result, 26);
} else {
return "";
}
} else {
return keyc + base64Encode(result1.toString()).replaceAll("=", "");
}
}
protected String ucFopen2(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) {
url += url.indexOf("?") > 0 ? "&" : "?" + "__times__=1";
return ucFopen(url, limit, post, cookie, bysocket, ip, timeout, block);
}
/**
* 本地模网络请求取数据
*
* @param url 打开的url
* @param limit 取返回的数据的长度
* @param post 要发送的 POST 数据如uid=1&password=1234
* @param cookie 要模拟的 COOKIE 数据如uid=123&auth=a2323sd2323
* @param bysocket TRUE/FALSE 是否通过SOCKET打开
* @param ip IP地址
* @param timeout 连接超时时间
* @param block 是否为阻塞模式 defaul valuet:true
* @return 取到的字符串
*/
private String ucFopen(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) {
StringBuilder result = new StringBuilder();
URL matches;
String host = "";
String path = "";
int port = 80;
try {
matches = new URL(url);
host = matches.getHost();
path = matches.getPath() != null ? matches.getPath() + (matches.getQuery() != null ? "?" + matches.getQuery() : "") : "/";
if (matches.getPort() > 0) port = matches.getPort();
} catch (Exception e1) {
FRContext.getLogger().info(e1.getMessage());
}
StringBuilder out = new StringBuilder();
if (post != null && post.length() > 0) {
out.append("POST ").append(path).append(" HTTP/1.0\r\n");
out.append("Accept: */*\r\n");
out.append("Accept-Language: zh-cn\r\n");
out.append("Content-Type: application/x-www-form-urlencoded\r\n");
out.append("User-Agent: \r\n");
out.append("Host: ").append(host).append("\r\n");
out.append("Content-Length: ").append(post.length()).append("\r\n");
out.append("Connection: Close\r\n");
out.append("Cache-Control: no-cache\r\n");
out.append("Cookie: \r\n\r\n");
out.append(post);
} else {
out.append("GET $path HTTP/1.0\r\n");
out.append("Accept: */*\r\n");
out.append("Accept-Language: zh-cn\r\n");
out.append("User-Agent: Java/1.5.0_01\r\n");
out.append("Host: $host\r\n");
out.append("Connection: Close\r\n");
out.append("Cookie: $cookie\r\n\r\n");
}
try {
Socket fp = new Socket(ip != null && ip.length() > 10 ? ip : host, port);
if (!fp.isConnected()) {
return "";
} else {
OutputStream os = fp.getOutputStream();
os.write(out.toString().getBytes());
InputStream ins = fp.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ins, "iso-8859-1"));
while (true) {
String header = reader.readLine();
if (header == null || "".equals(header) || Objects.equals(header, "\r\n") || Objects.equals(header, "\n")) {
break;
}
}
while (true) {
String data = reader.readLine();
if (data == null || "".equals(data)) {
break;
} else {
result.append(data);
}
}
fp.close();
}
} catch (IOException e) {
FRContext.getLogger().info(e.getMessage());
}
return result.toString();
}
}

41
designer-base/src/main/java/com/fr/design/extra/ucenter/XMLHelper.java

@ -1,41 +0,0 @@
package com.fr.design.extra.ucenter;
import com.fr.base.FRContext;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.StringReader;
import java.util.LinkedList;
/**
* @author lp
* @date 2016/9/9
*/
public class XMLHelper {
public static LinkedList<String> ucUnserialize(String input) {
LinkedList<String> result = new LinkedList<String>();
DOMParser parser = new DOMParser();
try {
parser.parse(new InputSource(new StringReader(input)));
Document doc = parser.getDocument();
NodeList nl = doc.getChildNodes().item(0).getChildNodes();
int length = nl.getLength();
for (int i = 0; i < length; i++) {
if (nl.item(i).getNodeType() == Document.ELEMENT_NODE) {
result.add(nl.item(i).getTextContent());
}
}
} catch (SAXException e) {
FRContext.getLogger().info(e.getMessage());
} catch (IOException e1) {
FRContext.getLogger().info(e1.getLocalizedMessage());
}
return result;
}
}

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

@ -2,9 +2,11 @@ package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory;
@ -58,6 +60,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
//直接关闭模板的时候退出权限编辑
if (DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().closeAuthorityEditing();
}
if (contains(selected) == -1) {
return;
}
@ -99,6 +105,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
return this.editingTemplate;
}
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt;
//如果当前历史面板中没有
@ -178,10 +188,13 @@ public class HistoryTemplateListCache implements CallbackEvent {
/**
* 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板
*
* @param filename 文件名
* @return 文件位置
* @deprecated use HistoryTemplateListCache#contains(com.fr.design.mainframe.JTemplate) instead
*/
@Deprecated
public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath();

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

@ -1,6 +1,7 @@
package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
@ -60,6 +61,10 @@ public class HistoryTemplateListPane implements CallbackEvent {
return instead().getCurrentEditingTemplate();
}
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> 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.ProductConstants;
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.server.lock.TplOperator;
@ -206,8 +205,7 @@ public class MutilTempalteTabPane extends JComponent {
openedTemplate.remove(jTemplate);
closeFormat(jTemplate);
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(jTemplate.getPath());
closeAndFreeLock(jTemplate);
}
}
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -221,7 +219,6 @@ public class MutilTempalteTabPane extends JComponent {
if (openedTemplate.size() == 1) {
closeOther.setEnabled(false);
}
return closeOther;
}
@ -676,9 +673,6 @@ public class MutilTempalteTabPane extends JComponent {
return;
}
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getPath();
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing();
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) {
specifiedTemplate.saveTemplate();
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) {
closeTpl(specifiedTemplate, filename);
closeTpl(specifiedTemplate);
}
} 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);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
activeTemplate(fileName);
closeAndFreeLock(specifiedTemplate);
activePrevTemplateAfterClose();
}
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()) {
//新建并激活模板
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
@ -736,23 +736,20 @@ public class MutilTempalteTabPane extends JComponent {
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
} else {
//如果关闭的模板是当前选中的模板,则重新激活
if (closeIconIndex == selectedIndex) {
if (closeIconIndex == maxPaintIndex) {
// 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
// selectIndex 没有变化,但是对应的模板已经变成了前一张模板
if (closeIconIndex == selectedIndex || isCloseCurrent) {
// 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界
if (closeIconIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex--;
}
} else if (isCloseCurrent) {
//不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活
if (selectedIndex > openedTemplate.size() - 1) {
selectedIndex -= 1;
if (selectedIndex < 0) {
selectedIndex = 0;
}
isCloseCurrent = false;
}
} else {
//如果关闭的模板不是当前选中的模板,则激活的模板不变
selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName);
isCloseCurrent = false;
}
// 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
else {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = HistoryTemplateListCache.getInstance().contains(template);
}
//如果是已后台关闭的模板,则重新打开文件
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 {
protected VariableTreeAndDescriptionArea variableTreeAndDescriptionArea;
protected RSyntaxTextArea formulaTextArea;
protected UITextField keyWordTextField = new UITextField(18);
protected int currentPosition = 0;
protected int beginPosition = 0;
protected int insertPosition = 0;
protected JList tipsList;
private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea;
private RSyntaxTextArea formulaTextArea;
private UITextField keyWordTextField = new UITextField(18);
private int currentPosition = 0;
private int beginPosition = 0;
private int insertPosition = 0;
private JList tipsList;
protected DefaultListModel listModel = new DefaultListModel();
protected int ifHasBeenWriten = 0;
protected DefaultListModel functionTypeListModel = new DefaultListModel();
protected QuickList functionTypeList;
protected DefaultListModel functionNameModel;
protected JList functionNameList;
private int ifHasBeenWriten = 0;
private DefaultListModel functionTypeListModel = new DefaultListModel();
private QuickList functionTypeList;
private DefaultListModel functionNameModel;
private JList functionNameList;
public FormulaPane() {
initComponents();
@ -184,6 +184,18 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected void initComponents() {
this.setLayout(new BorderLayout(4, 4));
initTextPane();
initTipsPane();
initVariableTreeAndDescriptionArea();
}
private void initVariableTreeAndDescriptionArea() {
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
}
private void initTextPane() {
// text
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(textPane, BorderLayout.CENTER);
@ -199,7 +211,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER);
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH);
initTipsPane();
UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid"));
checkValidButton.addActionListener(checkValidActionListener);
@ -209,8 +220,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST);
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST);
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.setAnimateBracketMatching(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) {
int signOfContinue = 1;
int indexOfFunction = 0;
@ -346,7 +355,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
protected int getBeginPosition() {
private int getBeginPosition() {
int i = currentPosition;
String textArea = formulaTextArea.getText();
for (; i > 0; i--) {
@ -361,7 +370,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return i;
}
protected void firstStepToFindTips(int theBeginPosition) {
private void firstStepToFindTips(int theBeginPosition) {
String textArea = formulaTextArea.getText();
if (currentPosition > 0 && theBeginPosition < currentPosition) {
@ -443,7 +452,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
/**
* Apply text.
*/
public void applyText(String text) {
private void applyText(String text) {
if (text == null || text.length() <= 0) {
return;
}
@ -541,7 +550,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
// check valid
protected ActionListener checkValidActionListener = new ActionListener() {
private ActionListener checkValidActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// Execute Formula default cell element.
@ -579,7 +588,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private JTree variablesTree;
private UITextArea descriptionTextArea;
public VariableTreeAndDescriptionArea() {
VariableTreeAndDescriptionArea() {
this.initComponents();
}
@ -802,13 +811,15 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private void initComponents() {
this.setLayout(new BorderLayout(4, 4));
// Function
initVariablesTree();
initFunctionPane();
}
private void initFunctionPane() {
JPanel functionPane = new JPanel(new BorderLayout(4, 4));
this.add(functionPane, BorderLayout.WEST);
initFunctionTypeList(functionPane);
initFunctionNameList(functionPane);
initVariablesTree();
// 选择:
functionTypeList.setSelectedIndex(0);
}
@ -959,7 +970,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private Icon icon;
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.icon = icon;
this.subNodes = subNodes;
@ -986,11 +997,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public static class TextUserObject {
public TextUserObject(String text) {
TextUserObject(String text) {
this(text, text);
}
public TextUserObject(String text, String displayText) {
TextUserObject(String text, String displayText) {
this.text = text;
this.displayText = displayText;
}
@ -999,7 +1010,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return this.text;
}
public String getDisplayText() {
String getDisplayText() {
return this.displayText;
}

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

@ -13,6 +13,8 @@ import com.fr.function.SUM;
import com.fr.function.TIME;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.ExtraClassManager;
import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem;
@ -34,13 +36,88 @@ import java.util.zip.ZipFile;
import javax.swing.DefaultListModel;
public abstract class FunctionConstants {
public final class FunctionConstants {
public static FunctionGroup PLUGIN = getPluginFunctionGroup();
public static FunctionGroup CUSTOM = getCustomFunctionGroup();
static NameAndFunctionList COMMON = getCommonFunctionList();
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
*/
public static void addFunctionGroupFromPlugins(DefaultListModel listModel){
static void addFunctionGroupFromPlugins(DefaultListModel listModel){
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
@ -74,107 +151,15 @@ 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) {
java.util.List<String> classNameList = new ArrayList<String>();
/*
* alex:如果是jar包中的class文件
* 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 jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符
String classPath = arr[1];
@ -197,7 +182,7 @@ public abstract class FunctionConstants {
}
String entryName = entry.getName();
if (entryName.indexOf(classPath) < 0 || !entryName.endsWith(".class")) {
if (!entryName.contains(classPath) || !entryName.endsWith(".class")) {
continue;
}
@ -208,57 +193,117 @@ public abstract class FunctionConstants {
}
} else {
File dir = new File(filePath);
for (File f : dir.listFiles()) {
String fileName = f.getName();
if (fileName.endsWith(".class")) {
classNameList.add(fileName);
File[] files = dir.listFiles();
if (files != null) {
for (File f : files) {
String fileName = f.getName();
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类
static {
String pkgName = "com.fr.function";
Class<Function> iface = Function.class;
ClassLoader classloader = iface.getClassLoader();
URL url = classloader.getResource(pkgName.replace('.', '/'));
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);
/*
* alex:如果是jar包中的class文件
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function
*/
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 (int fi = 0; fi < EMBFUNCTIONS.length; fi++) {
if (EMBFUNCTIONS[fi].test(inst)) {
break;
}
private static FunctionGroup getPluginFunctionGroup() {
return 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;
}
};
}
private static FunctionGroup getCustomFunctionGroup() {
return 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;
}
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
return new NameAndDescription[0];
}
}
};
}
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) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (menuItem == null) {
return;
}
LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font");
}
});
thread.setName("UIBasicMenuItemUI");
thread.setDaemon(true);
thread.start();
if (menuItem == null) {
return;
}
LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font");
}
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,

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

@ -1,11 +1,9 @@
package com.fr.design.gui.itextfield;
import com.fr.design.gui.imenu.UIListPopup;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
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.DocumentListener;
import javax.swing.event.ListSelectionEvent;
@ -13,10 +11,12 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.text.AbstractDocument;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener {
@ -82,9 +82,6 @@ public class UIAutoCompletionField extends UITextField implements DocumentListen
}
private void textChanged() {
if (OperatingSystem.isMacOS()) {
return;
}
if (!popup.isVisible()) {
showPopup();
requestFocus();

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 (lock != null && !node.getUserID().equals(lock)) {
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 {
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.design.icon.LockIcon;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
@ -125,8 +126,16 @@ public class FileTreeIcon {
return FOLDER_HALF_IMAGE_ICON;
}
/**
* 获取文件节点对应的图标
*
* @param node 文件节点
* @return 文件节点的图标
*/
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) {

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

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

57
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.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
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.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
@ -29,6 +31,7 @@ import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -76,7 +79,6 @@ import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
@ -160,9 +162,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//用于判断设计器是否打开了
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() {
@ -224,16 +226,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public void mouseReleased(MouseEvent e) {
if (DesignerMode.isAuthorityEditing()) {
DesignerMode.setMode(DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
DesignerContext.getDesignerFrame().resetToolkitByPlus(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus());
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
if (DesignModeContext.isAuthorityEditing()) {
closeAuthorityEditing();
}
}
@ -332,6 +326,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
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.
*
@ -849,18 +855,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) {
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,
JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && 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()));
}
} else {
if (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()));
}
}
@ -957,8 +963,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(
this,
Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME,
JOptionPane.INFORMATION_MESSAGE
);
DesignerFrameFileDealerPane.getInstance().refresh();
return;
}
@ -968,7 +978,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} catch (DecryptTemplateException e) {
JOptionPane.showMessageDialog(
this,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
@ -1027,7 +1037,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
} else {
activeTemplate(tplFile, jt);
activeTemplate(jt);
}
opened = true;
break;
@ -1042,13 +1052,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 激活指定的模板
*
* @param tplFile 模板文件
* @param jt 当前报表
* @param jt 当前报表
* @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();
if (index != -1) {
historyList.get(index).activeJTemplate(index, jt);

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()) {
propertyCard.show(rightPane, tabName);
propertyItem.setTabButtonSelected();
//从单元格菜单过来也要关闭弹出窗
hideCurrentPopupPane();
}
}

33
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.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
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.StringUtils;
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.Icon;
@ -72,7 +75,7 @@ import java.util.regex.Pattern;
/**
* 报表设计和表单设计的编辑区域(设计器编辑的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
private static final int PREFIX_NUM = 3000;
private FILE editingFILE = null;
@ -419,7 +422,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
fireSuperTargetModified();
}
protected boolean accept(Object o) {
public boolean accept(Object o) {
return true;
}
@ -587,6 +590,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (isCancelOperation(chooseResult)) {
return false;
}
// 源文件
FILE sourceFile = editingFILE;
if (isOkOperation(chooseResult)) {
boolean access = false;
@ -596,13 +601,33 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
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;
}
// 目标文件
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) {

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

@ -1,6 +1,8 @@
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 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 backgroundColorPane;
private PatternButton[] patternButtonArray;
@ -52,7 +54,8 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
}
foregroundColorPane = new ColorSelectBox(60);
backgroundColorPane = new ColorSelectBox(60);
foregroundColorPane.setSelectObject(DEFAULT_FOREGROUND);
foregroundColorPane.setSelectObject(DEFAULT_BACKGROUND);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
@ -219,7 +222,7 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override
public void reset() {
patternButtonArray[0].setSelected(true);
foregroundColorPane.setSelectObject(null);
backgroundColorPane.setSelectObject(null);
foregroundColorPane.setSelectObject(DEFAULT_FOREGROUND);
backgroundColorPane.setSelectObject(DEFAULT_BACKGROUND);
}
}

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

@ -68,4 +68,11 @@ public class LogMessageBar extends JPanel {
public Dimension getPreferredSize() {
return new Dimension(width, 24);
}
public void disposeLogDialog() {
if (dlg != null) {
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.cardtag.mobile.DefaultMobileTemplateStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane {
@ -40,17 +44,17 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
@Override
public MobileTemplateStyle updateBean() {
return new DefaultMobileTemplateStyle();
return getDefaultTemplateStyle();
}
public MobileTemplateStyle updateConfig(){
return new DefaultMobileTemplateStyle();
return getDefaultTemplateStyle();
}
@Override
protected MobileTemplateStyle getDefaultTemplateStyle() {
return new DefaultMobileTemplateStyle();
return new DefaultMobileTemplateStyle(new TabFontConfig(getTagLayout().getTitleFont()));
}
@Override
@ -73,6 +77,10 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
this.setBackground(DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR);
}
public Color getInitialColor() {
return DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR;
}
public void repaint() {
super.repaint();
}
@ -84,7 +92,8 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
int panelWidth = dimension.width;
int panelHeight = dimension.height;
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);
WCardTagLayout cardTagLayout = DefaultMobileStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
@ -92,11 +101,13 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
int fontHeight = fm.getHeight();
int ascentHeight = fm.getAscent();
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText();
int width = fm.stringWidth(widgetName);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(displayName);
g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
if (i == 0) {
g2d.setColor(Color.BLACK);
g2d.setStroke(new BasicStroke(2.0f));
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.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.util.ArrayList;
@ -151,6 +152,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
int panelWidth = dimension.width;
int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = DownMenuStyleDefinePane.this.getTagLayout();
@ -161,8 +163,8 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText();
int width = fm.stringWidth(widgetName);
String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(displayName);
if(i == 0){
Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor());
@ -171,7 +173,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
}
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.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();
if (splitLine.getLineStyle() != 0) {
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();
ob.setCustom(custom.getSelectedIndex() == 1);
ob.setInitialColor(initialColorBox.getSelectObject());
TabFontConfig config = ob.getTabFontConfig();
TabFontConfig config = new TabFontConfig();
config.setSelectColor(ob.getTabFontConfig().getSelectColor());
config.setFont(fontConfPane.update());
ob.setTabFontConfig(config);
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.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane {
private NewColorSelectBox initDotColor;
@ -131,6 +132,7 @@ public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane {
Dimension dimension = this.getSize();
int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
g2d.setFont(frFont);
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.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
@ -97,7 +98,10 @@ public abstract class StyleDefinePaneWithSelectConf extends MobileTemplateStyleD
public MobileTemplateStyle updateSubStyle() {
MobileTemplateStyle mobileTemplateStyle = updateStyleWithSelectConf();
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;
}

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) {
StyleDefinePaneUI styleDefinePaneUI = defineMap.get(style);
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = styleDefinePaneUI.getaClass();
if (clazz == null) {
if(styleDefinePaneUI == null){
styleDefinePaneUI = defineMap.get(DefaultMobileTemplateStyle.STYLE_NAME);
}
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = styleDefinePaneUI.getaClass();
BasicBeanPane<MobileTemplateStyle> quickPane = null;
try {
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.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
@ -171,7 +172,8 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
int panelWidth = dimension.width;
int panelHeight = dimension.height;
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);
WCardTagLayout cardTagLayout = UpMenuStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
@ -186,15 +188,15 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText();
int width = fm.stringWidth(widgetName);
String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(displayName);
if(i == 0){
Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor());
g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2);
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();
if (i == 0) {
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 java.awt.Color;
import java.awt.FontMetrics;
public abstract class MobileTemplatePreviewPane extends JPanel {
private Color initialColor;
@ -35,18 +36,32 @@ public abstract class MobileTemplatePreviewPane extends JPanel {
this.tabFontConfig = tabFontConfig;
}
public MobileTemplatePreviewPane(){
public MobileTemplatePreviewPane() {
}
public void populateConfig(MobileTemplateStyle templateStyle){
public void populateConfig(MobileTemplateStyle templateStyle) {
this.setInitialColor(templateStyle.getInitialColor());
this.setBackground(templateStyle.getInitialColor());
this.setSelectColor(templateStyle.getSelectColor());
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();
}

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.mainframe.DesignerContext;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
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.ActionListener;
import java.awt.event.MouseAdapter;
@ -92,11 +97,15 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
centerPane.add(Box.createVerticalStrut(1));
// 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
public void actionPerformed(ActionEvent e) {
public void mousePressed(MouseEvent e) {
if (!customButton.isEnabled()) {
return;
}
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.UIBasicButtonUI;
import javax.swing.*;
import javax.swing.plaf.ButtonUI;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.Cursor;
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.
@ -28,7 +32,7 @@ class PickColorButtonFactory {
* @return SpecialUIButton 屏幕取色按钮
*/
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;
if (iconType == IconType.ICON16) {
@ -42,9 +46,13 @@ class PickColorButtonFactory {
pickColorButton.setPreferredSize(new Dimension(iconSize, iconSize));
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
pickColorButton.addActionListener(new ActionListener() {
// 不能使用 ActionListener,否则设计器工具栏中的取色按钮会有问题(REPORT-13654)
pickColorButton.addMouseListener(new MouseAdapter() {
@Override
public void actionPerformed(ActionEvent e) {
public void mousePressed(MouseEvent e) {
if (!pickColorButton.isEnabled()) {
return;
}
new ColorPicker(colorSelectable, setColorRealTime);
}
});

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

@ -511,14 +511,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkspaceConnectionInfo connection = remoteEnv.getConnection();
DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath());
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try {
@ -532,18 +532,26 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
protected void done() {
okButton.setEnabled(true);
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"));
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) {
FineLoggerFactory.getLogger().error(e, e.getMessage());

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;
}
}
}

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();
//防止初始的时候有空白选项
if (editorName == null) {
return;
String[] formHyperlinkEditNames = getFormHyperlinkEditNames();
if (editorName == null && formHyperlinkEditNames.length > 0) {
editorName = formHyperlinkEditNames[0];
formHyperlink.setRelateEditorName(editorName);
}
if (targetFrameComboBox != null) {
//noinspection unchecked
targetFrameComboBox.setModel(new DefaultComboBoxModel(getFormHyperlinkEditNames()));
targetFrameComboBox.setModel(new DefaultComboBoxModel(formHyperlinkEditNames));
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();
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"));
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"));
lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
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};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);
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));
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};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);
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"));
lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
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};
isNullValueBreak = new UIButtonGroup<Boolean>(nameArray, valueArray);
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"));
lineStyle = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
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};
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.layout.TableLayout;
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.table.DataPaneHelper;
import com.fr.stable.StringUtils;
@ -49,7 +50,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER);
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);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
@ -134,7 +135,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractData
};
double p = TableLayout.PREFERRED;
double[] columnSize = {76, 120};
double[] columnSize = {78, 122};
double[] rowSize = {p, p, p};
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.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -28,7 +29,7 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
double[] columnSize = {f, e};
double[] rowSize = {p};
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);
this.setLayout(new BorderLayout());
@ -36,8 +37,8 @@ public class VanChartBeautyPane extends BasicBeanPane<Integer> {
}
protected String[] getNameArray(){
return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Name"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Top_Down_Shade")
return new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Name"),
Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade")
};
}
@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;
import com.fr.design.i18n.Toolkit;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel;
@ -18,6 +19,7 @@ public class CategoryNameFormatPaneWithCheckBox extends VanChartFormatPaneWithCh
@Override
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");
}
}

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) {
if (stylePane != null) {
panel.add(createStylePane(), BorderLayout.CENTER);
panel.add(stylePane, BorderLayout.CENTER);
}
panel.add(createAlphaPane(), BorderLayout.SOUTH);
}

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.iofile.attr.MobileOnlyTemplateAttrMark;
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.DialogActionAdapter;
import com.fr.design.form.mobile.FormMobileAttrPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.menu.MenuKeySet;
@ -73,6 +77,9 @@ public class FormMobileAttrAction extends JTemplateAction<JForm> {
formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后
((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified();
jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent());
//改变布局为自适应布局,只在移动端属性设置保存后改变一次
doChangeBodyLayout();
WidgetPropertyPane.getInstance().refreshDockingView();
jf.fireTargetModified();
}
@ -80,6 +87,15 @@ public class FormMobileAttrAction extends JTemplateAction<JForm> {
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)
private void recordFunction() {
// 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.location.Direction;
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.FormSelectionUtils;
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.util.ArrayList;
@ -94,8 +104,11 @@ public class StateModel {
return;
}
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XLayoutContainer container = getMouseLocationContainer(e);
if (container == null) {
return;
}
XCreator creator = selectionModel.getSelection().getSelectedCreator();
Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator);
if (creatorContainer != null && creatorContainer != container
@ -141,11 +154,8 @@ public class StateModel {
* @param mouseReleasedY 鼠标释放位置Y
*/
private void adding(int mouseReleasedX, int mouseReleasedY) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators());
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
// 当前鼠标所在组件的容器
XLayoutContainer container = getMouseLocationContainer(mouseReleasedX, mouseReleasedY);
boolean success = false;
@ -166,6 +176,33 @@ public class StateModel {
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) {
try {
designer.setCursor(XConnector.connectorCursor);
} catch (Exception e) {
} catch (Exception ignored) {
}
} else {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
@ -433,11 +470,11 @@ public class StateModel {
// 拖拽时画依附线用到的painter
private void setDependLinePainter(MouseEvent e) {
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators());
if (comp == null) {
XLayoutContainer container = getMouseLocationContainer(e);
if (container == null) {
return;
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp);
XCreator creator = selectionModel.getSelection().getSelectedCreator();
HoverPainter painter = AdapterBus.getContainerPainter(designer, container);
designer.setPainter(painter);
@ -479,9 +516,8 @@ public class StateModel {
* @return xy值
*/
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());
return p1;
}
}

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

@ -66,9 +66,11 @@ import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.StringUtils;
import com.fr.third.javax.annotation.Nonnull;
import javax.swing.*;
import java.awt.*;
import javax.swing.Icon;
import java.awt.Container;
import java.awt.Dimension;
/**
* XCreator的相关处理
@ -284,7 +286,7 @@ public class XCreatorUtils {
* @param creator 组件
* @return 返回顶层容器
*/
public static XLayoutContainer getHotspotContainer(XCreator creator) {
public static XLayoutContainer getHotspotContainer(@Nonnull XCreator creator) {
if (creator.isDedicateContainer()) {
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;
if (wc != null && (widget= wc.toWidget()) != null) {
editor = XCreatorUtils.createXCreator(widget);
toData().setVisible(widget.isVisible());
Widget currentWidget = toData();
currentWidget.setVisible(widget.isVisible());
currentWidget.setEnabled(widget.isEnabled());
this.setBorder(null);
} else {
this.setBorder(DEFALUTBORDER);

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);
}
/**
* 重置组件的名称
* @param name 名称
*/
public void resetCreatorName(String name) {
super.resetCreatorName(name);
changeRelateSwitchCardName(name);
}
@Override
protected void initLayoutManager() {
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.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.BorderFactory;
@ -324,10 +325,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
*/
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
designerActions = new ArrayList<UpdateAction>(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)}));
dmlActions(designerActions);
}
return designerActions;
return designerActions.toArray(new UpdateAction[designerActions.size()]);
}
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.designer.creator.XCreator;
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.ComponentTreeModel;
import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.utils.gui.GUICoreUtils;
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.TreePath;
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.MouseEvent;
import java.awt.image.BufferedImage;
@ -118,7 +127,9 @@ public class ComponentTree extends JTree {
public void setAndScrollSelectionPath(TreePath[] treepath) {
setSelectionPaths(treepath);
scrollPathToVisible(treepath[0]);
if (treepath.length > 0) {
scrollPathToVisible(treepath[0]);
}
}
@Override
@ -330,8 +341,7 @@ public class ComponentTree extends JTree {
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);
comp.paint(im.getGraphics());
return im;
@ -341,14 +351,14 @@ public class ComponentTree extends JTree {
private void updateSize() {
int width = compImage.getWidth();
int height = compImage.getHeight();
double aspectRatio = (double)width / height;
double aspectRatio = (double) width / height;
if (width > MAX_WIDTH) {
width = MAX_WIDTH;
height = (int)(width / aspectRatio);
height = (int) (width / aspectRatio);
}
if (height > MAX_HEIGHT) {
height = MAX_HEIGHT;
width = (int)(height * aspectRatio);
width = (int) (height * aspectRatio);
}
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;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext;
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.file.HistoryTemplateListPane;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
@ -62,6 +65,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.third.javax.annotation.Nullable;
import javax.swing.Action;
import javax.swing.JComponent;
@ -89,6 +93,7 @@ import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
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 CreatorEventListenerTable edit;
protected UpdateAction[] designerActions;
protected List<UpdateAction> designerActions;
private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer;
@ -914,7 +919,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @return 是则返回true
*/
public boolean isRoot(XCreator comp) {
return comp == rootComponent || comp.acceptType(XWAbsoluteBodyLayout.class);
return comp != null && (comp == rootComponent || comp.acceptType(XWAbsoluteBodyLayout.class));
}
// 计算鼠标事件e所发生的位置相对根组件的位置关系
@ -976,6 +981,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return getComponentAt(x, y, null);
}
@Nullable
public XCreator getComponentAt(int x, int y, XCreator[] except) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
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() {
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 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.MultiFileEditor;
import com.fr.form.ui.Widget;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.js.WidgetName;
@ -20,35 +19,38 @@ import com.fr.stable.js.WidgetName;
import java.util.ArrayList;
import java.util.List;
public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>> {
public FormModelAdapter(BaseJForm jForm) {
super(jForm);
}
public FormModelAdapter(BaseJForm<Form> jForm) {
super(jForm);
}
/**
* 环境改变.
*/
public void envChanged() {
WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets();
}
public void envChanged() {
WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets();
}
/**
* 参数改变.
*/
public void parameterChanged() {
//实时更新参数
jTemplate.populateParameter();
}
public void parameterChanged() {
//实时更新参数
jTemplate.populateParameter();
// 更新缓存的参数
updateCachedParameter();
}
/**
* 控件配置改变.
*/
public void widgetConfigChanged() {
WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets();
}
public void widgetConfigChanged() {
WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets();
}
/**
* 重命名TableData后的一些操作
@ -57,81 +59,80 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
if (super.renameTableData(oldName, newName)) {
jTemplate.refreshSelectedWidget();
return true;
}
return false;
}
@Override
public List<WidgetName> getWidgetsName() {
final List<WidgetName> list = new ArrayList<WidgetName>();
Form.traversalFormWidget(this.getBook().getContainer(), new WidgetGatherAdapter() {
@Override
public void dealWith(Widget widget) {
if (widget instanceof DataControl || widget instanceof MultiFileEditor) {
list.add(new WidgetName(widget.getWidgetName()));
}
}
});
return list;
}
/**
* 获取可以被超链的对象,表单主体中的所有控件
*/
public Widget[] getLinkableWidgets() {
final ArrayList<Widget> linkAbleList = new ArrayList<Widget>();
public boolean renameTableData(String oldName, String newName) {
if (super.renameTableData(oldName, newName)) {
jTemplate.refreshSelectedWidget();
return true;
}
return false;
}
@Override
public List<WidgetName> getWidgetsName() {
final List<WidgetName> list = new ArrayList<WidgetName>();
Form.traversalFormWidget(this.getBook().getContainer(), new WidgetGatherAdapter() {
@Override
public void dealWith(Widget widget) {
if (widget instanceof DataControl || widget instanceof MultiFileEditor) {
list.add(new WidgetName(widget.getWidgetName()));
}
}
});
return list;
}
/**
* 获取可以被超链的对象,表单主体中的所有控件
*/
public Widget[] getLinkableWidgets() {
final ArrayList<Widget> linkAbleList = new ArrayList<Widget>();
final JForm currentJForm = ((JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
Form.traversalWidget(currentJForm.getRootLayout(), new WidgetGatherAdapter() {
@Override
public boolean dealWithAllCards() {
return true;
}
public void dealWith(Widget widget) {
boolean isSupportAsHypelink = widget.acceptType(ElementCaseEditor.class) || widget.acceptType(BaseChartEditor.class);
//可以超链的对象不包含本身; 目前只有图表和报表块可以
// bug66182 删了条件:!ComparatorUtils.equals(editingECName, widget.getWidgetName()) 让当前表单对象可以选到自己
if (isSupportAsHypelink) {
linkAbleList.add(widget);
}
}
}, Widget.class);
return linkAbleList.toArray(new Widget[linkAbleList.size()]);
}
// 报表参数
@Override
public Parameter[] getReportParameters() {
Parameter[] rpa = this.getBook().getTemplateParameters();
return rpa == null ? new Parameter[0] : rpa;
}
// 数据源参数
@Override
public Parameter[] getTableDataParameters() {
TableDataSource source = this.getBook();
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());
if (td.getParameters(c) != null) {
list.addAll(java.util.Arrays.asList(td.getParameters(c)));
}
}
return list.toArray(new Parameter[list.size()]);
}
@Override
public Parameter[] getParameters() {
return this.getBook().getParameters();
}
Form.traversalWidget(currentJForm.getRootLayout(), new WidgetGatherAdapter() {
@Override
public boolean dealWithAllCards() {
return true;
}
public void dealWith(Widget widget) {
boolean isSupportAsHypelink = widget.acceptType(ElementCaseEditor.class) || widget.acceptType(BaseChartEditor.class);
//可以超链的对象不包含本身; 目前只有图表和报表块可以
// bug66182 删了条件:!ComparatorUtils.equals(editingECName, widget.getWidgetName()) 让当前表单对象可以选到自己
if (isSupportAsHypelink) {
linkAbleList.add(widget);
}
}
}, Widget.class);
return linkAbleList.toArray(new Widget[linkAbleList.size()]);
}
@Override
protected Parameter[] getLatestTemplateParameters() {
Parameter[] rpa = this.getBook().getTemplateParameters();
return rpa == null ? new Parameter[0] : rpa;
}
@Override
protected Parameter[] getLatestTableDataParameters() {
TableDataSource source = this.getBook();
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());
if (td.getParameters(c) != null) {
list.addAll(java.util.Arrays.asList(td.getParameters(c)));
}
}
return list.toArray(new Parameter[list.size()]);
}
@Override
protected Parameter[] getLatestParameters() {
return this.getBook().getParameters();
}
}

58
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.cardlayout.XWTabFitLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
@ -97,8 +96,7 @@ public class FormSelectionUtils {
Rectangle rec = clipboard.getSelctionBounds();
for (XCreator creator : clipboard.getSelectedCreators()) {
try {
Widget copied = copyWidget(designer, creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
XCreator copiedCreator = copyXcreator(designer.getTarget(), creator);
// 获取位置
Point point = getPasteLocation((AbstractLayoutAdapter) adapter,
copiedCreator,
@ -181,8 +179,7 @@ public class FormSelectionUtils {
private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) {
try {
Widget copied = copyWidget(designer, creator);
XCreator copiedXCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
XCreator copiedXCreator = copyXcreator(designer.getTarget(), creator);
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
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"));
@ -235,33 +232,52 @@ public class FormSelectionUtils {
return new Point(x, y);
}
/**
* 拷贝组件
* @param form 当前表单
* @param xCreator 待拷贝的组件
* @return XCreator 拷贝的组件
*/
private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws
CloneNotSupportedException {
ArrayList<String> nameSpace = new ArrayList<>();
public static XCreator copyXcreator(Form form, XCreator xCreator) throws CloneNotSupportedException{
Widget copied = (Widget) xCreator.toData().clone();
//重命名拷贝的组件
String name = getCopiedName(formDesigner, copied, nameSpace);
if (copied instanceof WTitleLayout) {
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) copied, xCreator.getSize());
xwTitleLayout.resetCreatorName(name);
} else {
copied.setWidgetName(name);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, xCreator.getSize());
ArrayList<String> nameSpace = new ArrayList<>();
copyWidgetName(form, nameSpace, copiedCreator);
return copiedCreator;
}
/**
* 拷贝组件
* @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());
do {
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());
return name.toString();
}
@ -308,4 +324,4 @@ public class FormSelectionUtils {
}
}
}
}
}

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.vcs.DesignerMode;
import com.fr.design.DesignState;
import com.fr.design.actions.FormMobileAttrAction;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.export.EmbeddedFormExportExportAction;
@ -86,7 +87,7 @@ import java.util.ArrayList;
import java.util.HashMap;
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 ELEMENTCASE_CARD = "ELEMENTCASE";
@ -139,7 +140,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return DesignState.JFORM;
}
public TemplateProcessInfo getProcessInfo() {
public TemplateProcessInfo<Form> getProcessInfo() {
if (processInfo == null) {
processInfo = new JFormProcessInfo(template);
}
@ -160,7 +161,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
@Override
protected boolean accept(Object o) {
public boolean accept(Object o) {
return !(o instanceof FloatElementsProvider);
}
@ -496,9 +497,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public ShortCut[] shortcut4TemplateMenu() {
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 {
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);
if (rootLayout != formDesigner.getRootComponent()
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) {
//原单例面板populate根据当前样式populate属性面板,现加入移动端逻辑:可能需要根据面板属性改变样式
Form form = formDesigner.getTarget();
if (form.getFormMobileAttr().isMobileOnly() && form.getFormMobileAttr().isAdaptivePropertyAutoMatch()) {
((XWFitLayout)formDesigner.getRootComponent()).switch2FitBodyLayout(rootLayout);
} else {
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
}
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
}
paddingBound.populate(ob);
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());
FRFont frFont = layoutBorderStyle.getTitle().getFrFont();
if (frFont != null) {
ob.setTitleFont(frFont);
frFontPane.populateBean(frFont);
}
}
@ -126,8 +127,10 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart();
LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle();
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();
layout.setTitleFont(titleFont);
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"))) {
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));

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

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

77
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.general.IOUtils;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import com.fr.transaction.WorkerCallBack;
import com.fr.transaction.WorkerFacade;
import javax.swing.*;
import java.awt.event.ActionEvent;
@ -21,16 +24,17 @@ import java.awt.event.ActionEvent;
* StyleList Action
*/
public class StyleListAction extends UpdateAction {
public StyleListAction() {
public StyleListAction() {
this.setMenuKeySet(PREDEFINED_STYLES);
this.setName(getMenuKeySet().getMenuKeySetName()+ "...");
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png"));
this.generateAndSetSearchText(StyleManagerPane.class.getName());
}
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png"));
this.generateAndSetSearchText(StyleManagerPane.class.getName());
}
/**
* 动作
*
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
@ -40,45 +44,44 @@ public class StyleListAction extends UpdateAction {
styleListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
Configurations.update(new Worker() {
Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) {
@Override
public void run() {
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();
styleListPane.populate(mirror);
styleListDialog.setVisible(true);
}
@Override
public void update() {
this.setEnabled(true);
}
ServerPreferenceConfig mirror = ServerPreferenceConfig.getInstance().mirror();
styleListPane.populate(mirror);
styleListDialog.setVisible(true);
}
@Override
public void update() {
this.setEnabled(true);
}
public static final MenuKeySet PREDEFINED_STYLES = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'K';
}
public static final MenuKeySet PREDEFINED_STYLES = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'K';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles");
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
@Override
public KeyStroke getKeyStroke() {
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;
import java.util.Arrays;
import java.util.Iterator;
import com.fr.base.FRContext;
import com.fr.grid.selection.CellSelection;
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.unit.FU;
import java.util.Arrays;
import java.util.Iterator;
/**
* The clip of CellElement.
*/
@ -39,7 +39,47 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
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());
// 排序

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) {
synchronized (CellElementPropertyPane.class) {
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());
Transferable clipData = clipboard.getContents(this);
@ -862,6 +862,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
/**
* 响应目标变动.
*/
@Override
public void fireTargetModified() {
// marks:自动计算
TemplateElementCase report = this.getEditingElementCase();

225
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.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.mainframe.errorinfo.ErrorInfoUploader;
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.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.intelli.record.FocusPoint;
import com.fr.intelli.record.MetricException;
import com.fr.intelli.record.MetricRegistry;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
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.ProductConstants;
import com.fr.stable.StableUtils;
@ -58,17 +48,15 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
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.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
/**
* @author neil
@ -79,7 +67,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
// 24小时上传一次
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 XML_START_STOP_LIST = "StartStopList";
private static final String XML_START_STOP = "StartStop";
@ -104,6 +92,8 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private static final String ATTR_TITLE = "title";
private static final String ATTR_USER_NAME = "username";
private static final String ATTR_UUID = "uuid";
private static final String ATTR_FUNCTION_ARRAY = "functionArray";
private static final int MAX_EACH_REQUEST_RECORD_COUNT = 200;
private static InformationCollector collector;
@ -168,7 +158,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}
private byte[] getJSONContentAsByte(){
private JSONObject getJSONContentAsByte(){
JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray();
@ -190,13 +180,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
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(){
@ -206,19 +190,17 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) {
return;
}
byte[] content = getJSONContentAsByte();
HttpClient hc = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("user.info"));
hc.setContent(content);
if (!hc.isServerAlive()) {
return;
}
String res = hc.getResponseText();
//服务器返回true,说明已经取得成功,清空当前记录的信息
JSONObject content = getJSONContentAsByte();
String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
boolean success = false;
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");
} catch (JSONException e) {
FRContext.getLogger().error(e.getMessage(), e);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success){
this.reset();
@ -232,21 +214,26 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) {
return;
}
ArrayList<Map<String, Object>> content = null;
content = getFunctionsContent(current, new Date(lastTime));
JSONArray content = getFunctionsContent(currentTime, lastTime);
boolean success = false;
FineLoggerFactory.getLogger().info("Start sent function records to the cloud center...");
String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD);
if(content.size() > 0){
for(int i=0; i<content.size(); i++){
success = sendFunctionRecord(url, content.get(i));
try {
for(int i=0;i<content.length();i++){
JSONArray functionArray = content.getJSONArray(i);
if(functionArray.length() > 0){
success = sendFunctionRecord(url, functionArray);
}
}
//服务器返回true, 说明已经获取成功, 更新最后一次发送时间
if (success) {
this.lastTime = dateToString();
FineLoggerFactory.getLogger().info("Function records successfully sent to the cloud center.");
}
}catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
FineLoggerFactory.getLogger().info("Function records successfully sent to the cloud center.");
// //先将发送压缩文件这段代码注释,之后提任务
//大数据量下发送压缩zip数据不容易丢失
// try {
@ -265,12 +252,14 @@ public class InformationCollector implements XMLReadable, XMLWriter {
// }
}
private boolean sendFunctionRecord(String url, Map<String,Object> record) {
private boolean sendFunctionRecord(String url, JSONArray record) {
boolean success = false;
try {
String recordUrl = url+"?token=" + SiteCenterToken.generateToken() + "&content="+URLEncoder.encode(new JSONObject(record).toString(), EncodeConstants.ENCODING_UTF_8);
String res = HttpToolbox.get(recordUrl);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", record);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -437,33 +426,67 @@ public class InformationCollector implements XMLReadable, XMLWriter {
});
}
public static ArrayList getFunctionsContent(Date current, Date last){
ArrayList<Map<String,Object>> records = new ArrayList<Map<String,Object>>();
public JSONArray getFunctionsContent(long current, long last) {
//记录当前条数,达到200条合并成一个请求
int count = 0;
JSONArray functionArray = new JSONArray();
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();
TreeSet<FunctionRecord> focusPointsList = new TreeSet<>();
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);
for(int i=0;i< focusPoints.getList().size();i++){
FocusPoint focusPoint = focusPoints.getList().get(i);
if(focusPoint != null){
if((++count <= MAX_EACH_REQUEST_RECORD_COUNT)){
focusPointsList.add(getOneRecord(focusPoint));
} else {
count = 0;
functionArray.put(setToJSONArray(focusPointsList));
focusPointsList.add(getOneRecord(focusPoint));
}
if(i == (focusPoints.getList().size() -1)){
functionArray.put(setToJSONArray(focusPointsList));
}
}
}
}
} catch (MetricException e) {
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return records;
return functionArray;
}
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;
}
private JSONArray setToJSONArray(Set set) throws JSONException {
JSONArray jsonArray = new JSONArray();
for(Iterator iter = set.iterator(); iter.hasNext(); ) {
FunctionRecord functionRecord = (FunctionRecord)iter.next();
com.fr.json.JSONObject record = new com.fr.json.JSONObject();
record.put(ATTR_ID, functionRecord.getId());
record.put(ATTR_TEXT, functionRecord.getText());
record.put(ATTR_SOURCE, functionRecord.getSource());
record.put(ATTR_TIME, functionRecord.getTime());
record.put(ATTR_TITLE, functionRecord.getTitle());
record.put(ATTR_USER_NAME, functionRecord.getUsername());
record.put(ATTR_UUID, functionRecord.getUuid());
jsonArray.put(record);
}
return jsonArray;
}
private class StartStopTime implements XMLReadable, XMLWriter {
@ -505,4 +528,84 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}
private class FunctionRecord implements Comparable{
private String id;
private String text;
private int source;
private long time;
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 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
public TemplateProcessInfo getProcessInfo() {
public TemplateProcessInfo<WorkBook> getProcessInfo() {
if (processInfo == null) {
processInfo = new JWorkBookProcessInfo(template);
}
@ -309,10 +309,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
centerPane.setUpPaneHeight(hasParameterPane() ? parameterPane.getPreferredSize().height : 0);
}
@Override
/**
*
*/
@Override
public void setComposite() {
super.setComposite();
reportComposite.setComponents();
@ -544,10 +544,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
// //////////////////////OLD BELOW/////////////////////////
// ////////////////////////////////////////////////////////
@Override
/**
* set target
*/
@Override
public void setTarget(WorkBook book) {
if (book == null) {
return;
@ -1098,7 +1099,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
FILE newFile = createNewEmptyFile();
//如果文件已经打开, 那么就覆盖关闭掉他
MutilTempalteTabPane.getInstance().closeFileTemplate(newFile);
final TemplateWorkBook tpl = this.getTarget();
final WorkBook tpl = this.getTarget();
// 弹出输入参数
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());
FileOutputStream fileOutputStream = new FileOutputStream(fullPath);
EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter();
exporter.export(fileOutputStream, (WorkBook) tpl, parameterMap);
exporter.export(fileOutputStream, tpl, parameterMap);
} catch (Exception e1) {
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);
// richie:当linearray不为空时,说明有了鼠标拖动,下面画由于鼠标拖动产生的效果.
if (!lineArray.isEmpty()) {
//REPORT-13572 点击切换会出现重影,保证:此时鼠标点击是没有放开的,才会绘制轨迹
if (!lineArray.isEmpty() && !isReleased) {
paintDragTab(g2d, textHeight, charWidth, textAscent);
}
@ -568,6 +569,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
* @param evt 鼠标事件
*/
public void mousePressed(MouseEvent evt) {
isReleased = false;
int reportcount = reportComposite.getEditingWorkBook().getReportCount();
if (scrollIndex < 0 || scrollIndex >= reportcount) {
return;
@ -749,7 +751,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
/**
* exchange workSheet
*
* @param workBook
* @param
* @param index1
* @param index2
* @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;
/**
*
* @author zhou
* @since 2012-7-26下午2:03:12
*/
public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook> {
public WorkBookModelAdapter(JWorkBook jworkbook) {
super(jworkbook);
}
@Override
public Parameter[] getParameters() {
return this.getBook().getParameters();
}
// 报表参数
@Override
public Parameter[] getReportParameters() {
ReportParameterAttr rpa = this.getBook().getReportParameterAttr();
return rpa == null ? new Parameter[0] : rpa.getParameters();
}
// 数据源参数
@Override
public Parameter[] getTableDataParameters() {
TableDataSource source = this.getBook();
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());
if (td.getParameters(c) != null) {
list.addAll(java.util.Arrays.asList(td.getParameters(c)));
}
}
return list.toArray(new Parameter[list.size()]);
}
/**
* 重命名TableData后的一些操作
* @param oldName 旧名字
* @param newName 新名字
* @return 返回是否刷新.
*/
public boolean renameTableData(String oldName, String newName) {
if (super.renameTableData(oldName, newName)) {
if (this.getBook().getTableData(oldName) == null) {
jTemplate.refreshParameterPane4TableData(oldName,newName);
}
return true;
}
return false;
}
/**
* 环境改变.
*/
public void envChanged() {
DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class);
if (provider != null) {
provider.refreshToolbar();
}
jTemplate.refreshAllNameWidgets();
}
/**
* 参数改变.
*/
public void parameterChanged() {
jTemplate.updateReportParameterAttr();
jTemplate.populateReportParameterAttr();
}
/**
* 控件改变.
*/
public void widgetConfigChanged() {
DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class);
if (provider != null) {
provider.refreshToolbar();
}
jTemplate.refreshAllNameWidgets();
}
/**
* 返回控件的名字
* @return widgetName 控件列表.
*/
public List<WidgetName> getWidgetsName() {
List<WidgetName> list = new ArrayList<WidgetName>();
WorkBook wb = this.getBook();
for (int i = 0, len = wb.getReportCount(); i < len; i++) {
Report report = wb.getReport(i);
Iterator it = report.iteratorOfElementCase();
while (it.hasNext()) {
ElementCase ec = (ElementCase)it.next();
Iterator cs = ec.cellIterator();
while (cs.hasNext()) {
CellElement ce = (CellElement)cs.next();
if (ce instanceof DefaultTemplateCellElement) {
Widget widget = ((DefaultTemplateCellElement)ce).getWidget();
if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) {
list.add(new WidgetName(widget.getWidgetName()));
}
}
}
}
}
return list;
}
/**
* 返回悬浮元素的名字数组
* @return 返回数组.
*/
public String[] getFloatNames() {
TemplateElementCase elementCase = jTemplate.getEditingElementCase();
List<String> nameList = new ArrayList<String>();
Iterator<FloatElement> it = elementCase.floatIterator();
while (it.hasNext()) {
nameList.add(it.next().getName());
}
return nameList.toArray(new String[nameList.size()]);
}
public WorkBookModelAdapter(JWorkBook jworkbook) {
super(jworkbook);
}
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字
* @return 返回是否刷新.
*/
public boolean renameTableData(String oldName, String newName) {
if (super.renameTableData(oldName, newName)) {
if (this.getBook().getTableData(oldName) == null) {
jTemplate.refreshParameterPane4TableData(oldName, newName);
}
return true;
}
return false;
}
/**
* 环境改变.
*/
public void envChanged() {
DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class);
if (provider != null) {
provider.refreshToolbar();
}
jTemplate.refreshAllNameWidgets();
}
/**
* 参数改变.
*/
public void parameterChanged() {
jTemplate.updateReportParameterAttr();
jTemplate.populateReportParameterAttr();
updateCachedParameter();
}
/**
* 控件改变.
*/
public void widgetConfigChanged() {
DesignToolbarProvider provider = StableFactory.getMarkedObject(DesignToolbarProvider.STRING_MARKED, DesignToolbarProvider.class);
if (provider != null) {
provider.refreshToolbar();
}
jTemplate.refreshAllNameWidgets();
}
@Override
protected Parameter[] getLatestTemplateParameters() {
ReportParameterAttr rpa = this.getBook().getReportParameterAttr();
return rpa == null ? new Parameter[0] : rpa.getParameters();
}
@Override
protected Parameter[] getLatestTableDataParameters() {
TableDataSource source = this.getBook();
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());
if (td.getParameters(c) != null) {
list.addAll(java.util.Arrays.asList(td.getParameters(c)));
}
}
return list.toArray(new Parameter[list.size()]);
}
@Override
protected Parameter[] getLatestParameters() {
return this.getBook().getParameters();
}
/**
* 返回控件的名字
*
* @return widgetName 控件列表.
*/
public List<WidgetName> getWidgetsName() {
List<WidgetName> list = new ArrayList<WidgetName>();
WorkBook wb = this.getBook();
for (int i = 0, len = wb.getReportCount(); i < len; i++) {
Report report = wb.getReport(i);
Iterator it = report.iteratorOfElementCase();
while (it.hasNext()) {
ElementCase ec = (ElementCase) it.next();
Iterator cs = ec.cellIterator();
while (cs.hasNext()) {
CellElement ce = (CellElement) cs.next();
if (ce instanceof DefaultTemplateCellElement) {
Widget widget = ((DefaultTemplateCellElement) ce).getWidget();
if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) {
list.add(new WidgetName(widget.getWidgetName()));
}
}
}
}
}
return list;
}
/**
* 返回悬浮元素的名字数组
*
* @return 返回数组.
*/
public String[] getFloatNames() {
TemplateElementCase elementCase = jTemplate.getEditingElementCase();
List<String> nameList = new ArrayList<String>();
Iterator<FloatElement> it = elementCase.floatIterator();
while (it.hasNext()) {
nameList.add(it.next().getName());
}
return nameList.toArray(new String[nameList.size()]);
}
public Widget[] getLinkableWidgets() {

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.config.ServerPreferenceConfig;
import com.fr.config.StyleMap;
import com.fr.design.gui.controlpane.AbstractNameableCreator;
import com.fr.design.gui.controlpane.JListControlPane;
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.stable.Nameable;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerAdaptor;
import java.util.ArrayList;
import java.util.Iterator;
@ -90,17 +93,16 @@ public class StyleArrayPane extends JListControlPane {
/**
* Update.
*/
public void update(ServerPreferenceConfig configManager) {
configManager.clearAllStyle();
public void update(final ServerPreferenceConfig configManager) {
//configManager.clearAllStyle();
// Nameable[]居然不能强转成Parameter[],一定要这么写...
Nameable[] nameables = this.update();
final StyleMap styleMap = new StyleMap();
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);
}
}

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.getDeleteMenu(ePane));
popup.add(DeprecatedActionManager.getClearMenu(ePane));
popup.addSeparator();
addExtraMenu(ePane, popup);
return popup;
}

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

@ -1,6 +1,5 @@
package com.fr.grid.selection;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
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.utils.DesignUtils;
import com.fr.general.ComparatorUtils;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
@ -149,6 +147,10 @@ public class FloatSelection extends Selection {
popup.add(new EditFloatElementNameAction(ePane).createMenuItem());
popup.addSeparator();
addExtraMenu(ePane, popup);
return popup;
}

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

@ -1,19 +1,22 @@
package com.fr.grid.selection;
import java.io.Serializable;
import javax.swing.JPopupMenu;
import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable;
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.report.elementcase.TemplateElementCase;
import com.fr.design.selection.SelectableElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.FCloneable;
import javax.swing.JPopupMenu;
import java.io.Serializable;
import java.util.Set;
/*
* 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 boolean isSelectedOneCell(ElementCasePane ePane);
// ///////////////////////////////copy/////////////////////////////////
public abstract void asTransferable(ElementsTransferable transferable, ElementCasePane ePane);
// ///////////////////////////////paste////////////////////////////////
public boolean pasteFloatElementClip(FloatElementsClip feClip, ElementCasePane ePane) {
FloatElementsClip floatElementClip;
try {
@ -53,7 +54,6 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
public abstract boolean pasteOtherType(Object ob, ElementCasePane ePane);
// ///////////////////////////////merge////////////////////////////////
public abstract boolean canMergeCells(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);
// ///////////////////////////////popup////////////////////////////////
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 int[] getSelectedRows();
public abstract int[] getSelectedColumns();
// //////////////////////////////move//////////////////////////////////
public abstract void moveLeft(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);
// //////////////////////////DeleteAction///////////////////////////////
public abstract boolean triggerDeleteAction(ElementCasePane ePane);
// //////////////////////////Just4CellSelection///////////////////////////////
public abstract boolean containsColumnRow(ColumnRow cr);
public abstract void populatePropertyPane(ElementCasePane ePane);

4
designer-realize/src/main/java/com/fr/start/Designer.java

@ -59,6 +59,7 @@ import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import java.awt.Component;
@ -121,6 +122,9 @@ public class Designer extends BaseDesigner {
try {
designerRoot.start();
} catch (LifecycleFatalError fatal) {
SplashContext.getInstance().hide();
JOptionPane.showMessageDialog(null, fatal.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal);
System.exit(0);
}

2
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -24,7 +24,7 @@ public class SplashContext {
public static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
public static final String SPLASH_CACHE_NAME = "splash_10.gif";
private static final int FETCH_ONLINE_MAX_TIMES = 10;
private static final int FETCH_ONLINE_MAX_TIMES = 50;
private static final SplashContext SPLASH_CONTEXT = new SplashContext();

Loading…
Cancel
Save