Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~hades/design into release/10.0

bugfix/10.0
Hades 6 years ago
parent
commit
9ac89fc27e
  1. 168
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  2. 2
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 36
      designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java
  4. 5
      designer-base/src/main/java/com/fr/design/designer/TargetComponent.java
  5. 5
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  6. 5
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  7. 26
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  8. 19
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  9. 11
      designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java
  10. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  11. 6
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java
  12. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java
  13. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java
  14. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java
  15. 21
      designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java
  16. 36
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java
  17. 66
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  18. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  19. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  20. 28
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  21. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  22. 17
      designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java
  23. 56
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java
  24. 9
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  25. 22
      designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java
  26. 1
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  27. 110
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  28. 11
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  29. 6
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  30. 68
      designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java
  31. 4
      designer-realize/src/main/java/com/fr/start/Designer.java
  32. 2
      designer-realize/src/main/java/com/fr/start/SplashContext.java

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

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

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

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

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

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

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

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

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

@ -5,6 +5,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -99,6 +100,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
return this.editingTemplate; return this.editingTemplate;
} }
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt; this.editingTemplate = jt;
//如果当前历史面板中没有 //如果当前历史面板中没有

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

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

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

@ -13,6 +13,7 @@ import com.fr.function.SUM;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
@ -66,7 +67,6 @@ public final class FunctionConstants {
while (urlEnumeration.hasMoreElements()) { while (urlEnumeration.hasMoreElements()) {
URL url = urlEnumeration.nextElement(); URL url = urlEnumeration.nextElement();
String classFilePath = url.getFile(); String classFilePath = url.getFile();
/* /*
* alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理 * alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理
* 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理 * 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理
@ -77,10 +77,9 @@ public final class FunctionConstants {
FRContext.getLogger().error(e1.getMessage(), e1); FRContext.getLogger().error(e1.getMessage(), e1);
} }
FRContext.getLogger().info("ClassFilePath:" + classFilePath); FRContext.getLogger().info("ClassFilePath:" + classFilePath);
/* if (isCustomFormulaPath(classFilePath)) {
* alex:如果是jar包中的class文件 continue;
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function }
*/
for (String fileName : findClassNamesUnderFilePath(classFilePath)) { for (String fileName : findClassNamesUnderFilePath(classFilePath)) {
try { try {
Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6)); Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6));
@ -94,9 +93,24 @@ public final class FunctionConstants {
} }
} }
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ignore) { } 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("!/");
} }
/** /**
@ -145,7 +159,7 @@ public final class FunctionConstants {
* alex:如果是jar包中的class文件 * alex:如果是jar包中的class文件
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function * file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function
*/ */
if (filePath.contains("!/")) { if (isJarPath(filePath)) {
String[] arr = filePath.split("!/"); String[] arr = filePath.split("!/");
String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符 String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符
String classPath = arr[1]; String classPath = arr[1];

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

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

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

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

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

@ -75,7 +75,7 @@ import java.util.regex.Pattern;
/** /**
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件) * 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/ */
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, JTemplateProvider, DesignerProxy { public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000; private static final int PREFIX_NUM = 3000;
private FILE editingFILE = null; private FILE editingFILE = null;

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

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

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

@ -95,9 +95,9 @@ public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane
int ascentHeight = fm.getAscent(); int ascentHeight = fm.getAscent();
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
if (i == 0) { if (i == 0) {
g2d.setStroke(new BasicStroke(2.0f)); g2d.setStroke(new BasicStroke(2.0f));
g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1); g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1);

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

@ -163,8 +163,8 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
if(i == 0){ if(i == 0){
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor()); g2d.setColor(this.getSelectColor());
@ -173,7 +173,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
} }
Icon icon = new Icon(PAINT_ICON, ICON_PATH); Icon icon = new Icon(PAINT_ICON, ICON_PATH);
g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null); g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null);
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent);
Stroke oldStroke = g2d.getStroke(); Stroke oldStroke = g2d.getStroke();
if (splitLine.getLineStyle() != 0) { if (splitLine.getLineStyle() != 0) {
g2d.setColor(splitLine.getColor()); g2d.setColor(splitLine.getColor());

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

@ -188,15 +188,15 @@ public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String widgetName = cardSwitchButton.getText(); String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(widgetName); int width = fm.stringWidth(displayName);
if(i == 0){ if(i == 0){
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor()); g2d.setColor(this.getSelectColor());
g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2); g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2);
g2d.setColor(oldColor); g2d.setColor(oldColor);
} }
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
Stroke oldStroke = g2d.getStroke(); Stroke oldStroke = g2d.getStroke();
if (i == 0) { if (i == 0) {
g2d.setColor(this.underLine.getColor()); g2d.setColor(this.underLine.getColor());

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

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

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

@ -1,14 +1,24 @@
package com.fr.design.formula; 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.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.Assert.fail;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
/** /**
* Created by plough on 2018/12/7. * Created by plough on 2018/12/7.
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest(GeneralUtils.class)
public class FunctionConstantsTest { public class FunctionConstantsTest {
@Test @Test
public void testNewInstanceFail() throws Exception { public void testNewInstanceFail() throws Exception {
@ -37,4 +47,30 @@ public class FunctionConstantsTest {
NameAndFunctionList commonFunctionList = FunctionConstants.COMMON; NameAndFunctionList commonFunctionList = FunctionConstants.COMMON;
assertEquals(9, commonFunctionList.getDescriptions().length); 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());
}
} }

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

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

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.PluginEvent;
import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.javax.annotation.Nonnull;
import javax.swing.*; import javax.swing.Icon;
import java.awt.*; import java.awt.Container;
import java.awt.Dimension;
/** /**
* XCreator的相关处理 * XCreator的相关处理
@ -284,7 +286,7 @@ public class XCreatorUtils {
* @param creator 组件 * @param creator 组件
* @return 返回顶层容器 * @return 返回顶层容器
*/ */
public static XLayoutContainer getHotspotContainer(XCreator creator) { public static XLayoutContainer getHotspotContainer(@Nonnull XCreator creator) {
if (creator.isDedicateContainer()) { if (creator.isDedicateContainer()) {
return (XLayoutContainer) creator.getParent(); return (XLayoutContainer) creator.getParent();
} }

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

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

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

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

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

@ -65,6 +65,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.third.javax.annotation.Nullable;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -918,7 +919,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isRoot(XCreator comp) { public boolean isRoot(XCreator comp) {
return comp == rootComponent || comp.acceptType(XWAbsoluteBodyLayout.class); return comp != null && (comp == rootComponent || comp.acceptType(XWAbsoluteBodyLayout.class));
} }
// 计算鼠标事件e所发生的位置相对根组件的位置关系 // 计算鼠标事件e所发生的位置相对根组件的位置关系
@ -980,6 +981,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return getComponentAt(x, y, null); return getComponentAt(x, y, null);
} }
@Nullable
public XCreator getComponentAt(int x, int y, XCreator[] except) { public XCreator getComponentAt(int x, int y, XCreator[] except) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
XCreator comp = xCreatorAt(x + formArea.getHorizontalValue(), y + formArea.getVerticalValue(), container, XCreator comp = xCreatorAt(x + formArea.getHorizontalValue(), y + formArea.getVerticalValue(), container,
@ -1191,8 +1193,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
} }
return designerActions.toArray(new UpdateAction[designerActions.size()]); return designerActions.toArray(new UpdateAction[designerActions.size()]);
} }
/** /**
* 扩展菜单项 * 扩展菜单项
*
* @param actions * @param actions
*/ */
public void dmlActions(List<UpdateAction> actions) { public void dmlActions(List<UpdateAction> actions) {
@ -1200,7 +1204,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG); Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) { for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) { if (handler.accept(this)) {
handler.dmlUpdateActions(this,actions); handler.dmlUpdateActions(this, actions);
} }
} }
} catch (Exception e) { } catch (Exception e) {

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

@ -12,7 +12,6 @@ import com.fr.form.ui.DataControl;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.MultiFileEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.js.WidgetName; import com.fr.stable.js.WidgetName;
@ -20,9 +19,9 @@ import com.fr.stable.js.WidgetName;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> { public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>> {
public FormModelAdapter(BaseJForm jForm) { public FormModelAdapter(BaseJForm<Form> jForm) {
super(jForm); super(jForm);
} }
@ -32,6 +31,7 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
public void envChanged() { public void envChanged() {
WidgetToolBarPane.refresh(); WidgetToolBarPane.refresh();
jTemplate.refreshAllNameWidgets(); jTemplate.refreshAllNameWidgets();
} }
/** /**
@ -40,6 +40,8 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
public void parameterChanged() { public void parameterChanged() {
//实时更新参数 //实时更新参数
jTemplate.populateParameter(); jTemplate.populateParameter();
// 更新缓存的参数
updateCachedParameter();
} }
/** /**
@ -106,16 +108,15 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
return linkAbleList.toArray(new Widget[linkAbleList.size()]); return linkAbleList.toArray(new Widget[linkAbleList.size()]);
} }
// 报表参数
@Override @Override
public Parameter[] getReportParameters() { protected Parameter[] getLatestTemplateParameters() {
Parameter[] rpa = this.getBook().getTemplateParameters(); Parameter[] rpa = this.getBook().getTemplateParameters();
return rpa == null ? new Parameter[0] : rpa; return rpa == null ? new Parameter[0] : rpa;
} }
// 数据源参数
@Override @Override
public Parameter[] getTableDataParameters() { protected Parameter[] getLatestTableDataParameters() {
TableDataSource source = this.getBook(); TableDataSource source = this.getBook();
Calculator c = Calculator.createCalculator(); Calculator c = Calculator.createCalculator();
c.setAttribute(TableDataSource.KEY, source); c.setAttribute(TableDataSource.KEY, source);
@ -131,7 +132,7 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm> {
} }
@Override @Override
public Parameter[] getParameters() { protected Parameter[] getLatestParameters() {
return this.getBook().getParameters(); return this.getBook().getParameters();
} }
} }

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

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

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

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

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

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

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

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

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

@ -104,6 +104,8 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private static final String ATTR_TITLE = "title"; private static final String ATTR_TITLE = "title";
private static final String ATTR_USER_NAME = "username"; private static final String ATTR_USER_NAME = "username";
private static final String ATTR_UUID = "uuid"; private static final String ATTR_UUID = "uuid";
private static final String ATTR_FUNCTION_ARRAY = "functionArray";
private static final int MAX_EACH_REQUEST_RECORD_COUNT = 200;
private static InformationCollector collector; private static InformationCollector collector;
@ -168,7 +170,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private byte[] getJSONContentAsByte(){ private JSONObject getJSONContentAsByte(){
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray(); JSONArray startStopArray = new JSONArray();
@ -190,13 +192,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
} }
return content;
try {
return content.toString().getBytes(EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().error(e.getMessage(), e);
return ArrayUtils.EMPTY_BYTE_ARRAY;
}
} }
private void sendUserInfo(){ private void sendUserInfo(){
@ -206,19 +202,17 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) { if (currentTime - lastTime <= DELTA) {
return; return;
} }
byte[] content = getJSONContentAsByte(); JSONObject content = getJSONContentAsByte();
HttpClient hc = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("user.info")); String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
hc.setContent(content);
if (!hc.isServerAlive()) {
return;
}
String res = hc.getResponseText();
//服务器返回true,说明已经取得成功,清空当前记录的信息
boolean success = false; boolean success = false;
try { try {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (JSONException e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (success){ if (success){
this.reset(); this.reset();
@ -232,21 +226,31 @@ public class InformationCollector implements XMLReadable, XMLWriter {
if (currentTime - lastTime <= DELTA) { if (currentTime - lastTime <= DELTA) {
return; return;
} }
ArrayList<Map<String, Object>> content = null; JSONArray content = null;
content = getFunctionsContent(current, new Date(lastTime)); try {
content = getFunctionsContent(currentTime, lastTime);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
boolean success = false; boolean success = false;
FineLoggerFactory.getLogger().info("Start sent function records to the cloud center..."); FineLoggerFactory.getLogger().info("Start sent function records to the cloud center...");
String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD); String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD);
if(content.size() > 0){ try {
for(int i=0; i<content.size(); i++){ for(int i=0;i<content.length();i++){
success = sendFunctionRecord(url, content.get(i)); JSONArray functionArray = content.getJSONArray(i);
if(functionArray.length() > 0){
success = sendFunctionRecord(url, functionArray);
}
} }
//服务器返回true, 说明已经获取成功, 更新最后一次发送时间 //服务器返回true, 说明已经获取成功, 更新最后一次发送时间
if (success) { if (success) {
this.lastTime = dateToString(); 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数据不容易丢失 //大数据量下发送压缩zip数据不容易丢失
// try { // try {
@ -265,11 +269,13 @@ 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; boolean success = false;
try { try {
String recordUrl = url+"?token=" + SiteCenterToken.generateToken() + "&content="+URLEncoder.encode(new JSONObject(record).toString(), EncodeConstants.ENCODING_UTF_8); HashMap<String, Object> para = new HashMap<>();
String res = HttpToolbox.get(recordUrl); para.put("token", SiteCenterToken.generateToken());
para.put("content", record);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -437,33 +443,51 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}); });
} }
public static ArrayList getFunctionsContent(Date current, Date last){ public static JSONArray getFunctionsContent(long current, long last) throws JSONException{
ArrayList<Map<String,Object>> records = new ArrayList<Map<String,Object>>(); //记录当前条数,达到200条合并成一个请求
int count = 0;
JSONArray functionArray = new JSONArray();
QueryCondition condition = QueryFactory.create() QueryCondition condition = QueryFactory.create()
.addRestriction(RestrictionFactory.lte(COLUMN_TIME, current)) .addRestriction(RestrictionFactory.lte(COLUMN_TIME, current))
.addRestriction(RestrictionFactory.gte(COLUMN_TIME, last)); .addRestriction(RestrictionFactory.gte(COLUMN_TIME, last));
try { try {
DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition); DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); JSONArray temp = new JSONArray();
String bbsUserName = MarketConfig.getInstance().getBbsUsername();
String uuid = envManager.getUUID();
if(!focusPoints.isEmpty()){ if(!focusPoints.isEmpty()){
for(FocusPoint focusPoint : focusPoints.getList()){ for(int i=0;i< focusPoints.getList().size();i++){
Map<String,Object> record = new HashMap<>(); FocusPoint focusPoint = focusPoints.getList().get(i);
if(focusPoint != null){
if((++count <= MAX_EACH_REQUEST_RECORD_COUNT)){
temp.put(getOneRecord(focusPoint));
} else {
count = 0;
functionArray.put(temp);
temp = new JSONArray();
temp.put(getOneRecord(focusPoint));
}
if(i == (focusPoints.getList().size() -1)){
functionArray.put(temp);
}
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return functionArray;
}
private static JSONObject getOneRecord(FocusPoint focusPoint) throws JSONException{
com.fr.json.JSONObject record = new com.fr.json.JSONObject();
record.put(ATTR_ID, focusPoint.getId()); record.put(ATTR_ID, focusPoint.getId());
record.put(ATTR_TEXT, focusPoint.getText()); record.put(ATTR_TEXT, focusPoint.getText());
record.put(ATTR_SOURCE, focusPoint.getSource()); record.put(ATTR_SOURCE, focusPoint.getSource());
record.put(ATTR_TIME, focusPoint.getTime().getTime()); record.put(ATTR_TIME, focusPoint.getTime().getTime());
record.put(ATTR_TITLE, focusPoint.getTitle()); record.put(ATTR_TITLE, focusPoint.getTitle());
record.put(ATTR_USER_NAME, bbsUserName); record.put(ATTR_USER_NAME, MarketConfig.getInstance().getBbsUsername());
record.put(ATTR_UUID, uuid); record.put(ATTR_UUID, DesignerEnvManager.getEnvManager().getUUID());
records.add(record); return record;
}
}
} catch (MetricException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return records;
} }
private class StartStopTime implements XMLReadable, XMLWriter { private class StartStopTime implements XMLReadable, XMLWriter {

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

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

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

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

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

@ -25,7 +25,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
*
* @author zhou * @author zhou
* @since 2012-7-26下午2:03:12 * @since 2012-7-26下午2:03:12
*/ */
@ -35,37 +34,10 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
super(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后的一些操作 * 重命名TableData后的一些操作
*
* @param oldName 旧名字 * @param oldName 旧名字
* @param newName 新名字 * @param newName 新名字
* @return 返回是否刷新. * @return 返回是否刷新.
@ -73,7 +45,7 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
public boolean renameTableData(String oldName, String newName) { public boolean renameTableData(String oldName, String newName) {
if (super.renameTableData(oldName, newName)) { if (super.renameTableData(oldName, newName)) {
if (this.getBook().getTableData(oldName) == null) { if (this.getBook().getTableData(oldName) == null) {
jTemplate.refreshParameterPane4TableData(oldName,newName); jTemplate.refreshParameterPane4TableData(oldName, newName);
} }
return true; return true;
} }
@ -97,6 +69,7 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
public void parameterChanged() { public void parameterChanged() {
jTemplate.updateReportParameterAttr(); jTemplate.updateReportParameterAttr();
jTemplate.populateReportParameterAttr(); jTemplate.populateReportParameterAttr();
updateCachedParameter();
} }
/** /**
@ -110,8 +83,36 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
jTemplate.refreshAllNameWidgets(); 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 控件列表. * @return widgetName 控件列表.
*/ */
public List<WidgetName> getWidgetsName() { public List<WidgetName> getWidgetsName() {
@ -121,12 +122,12 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
Report report = wb.getReport(i); Report report = wb.getReport(i);
Iterator it = report.iteratorOfElementCase(); Iterator it = report.iteratorOfElementCase();
while (it.hasNext()) { while (it.hasNext()) {
ElementCase ec = (ElementCase)it.next(); ElementCase ec = (ElementCase) it.next();
Iterator cs = ec.cellIterator(); Iterator cs = ec.cellIterator();
while (cs.hasNext()) { while (cs.hasNext()) {
CellElement ce = (CellElement)cs.next(); CellElement ce = (CellElement) cs.next();
if (ce instanceof DefaultTemplateCellElement) { if (ce instanceof DefaultTemplateCellElement) {
Widget widget = ((DefaultTemplateCellElement)ce).getWidget(); Widget widget = ((DefaultTemplateCellElement) ce).getWidget();
if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) { if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) {
list.add(new WidgetName(widget.getWidgetName())); list.add(new WidgetName(widget.getWidgetName()));
} }
@ -139,6 +140,7 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
/** /**
* 返回悬浮元素的名字数组 * 返回悬浮元素的名字数组
*
* @return 返回数组. * @return 返回数组.
*/ */
public String[] getFloatNames() { public String[] getFloatNames() {

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 com.fr.workspace.WorkContext;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.Component; import java.awt.Component;
@ -121,6 +122,9 @@ public class Designer extends BaseDesigner {
try { try {
designerRoot.start(); designerRoot.start();
} catch (LifecycleFatalError fatal) { } 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); 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_PATH = "/com/fr/design/images/splash_10.gif";
public static final String SPLASH_CACHE_NAME = "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(); private static final SplashContext SPLASH_CONTEXT = new SplashContext();

Loading…
Cancel
Save