From b749d6115ef64057b211900d6510dfb5f44aa3b8 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 12 Dec 2018 11:58:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-13457=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=8F=82=E6=95=B0=E9=9D=A2=E6=9D=BF=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98=20&=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E5=9C=BA=E6=99=AF=E7=9A=84=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88=E5=92=8C=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=EF=BC=8C=E6=B3=9B=E5=9E=8B=E6=94=B9=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignModelAdapter.java | 170 +++++++++--- .../fr/design/designer/TargetComponent.java | 5 +- .../design/file/HistoryTemplateListCache.java | 5 + .../design/file/HistoryTemplateListPane.java | 5 + .../com/fr/design/mainframe/BaseJForm.java | 11 +- .../com/fr/design/mainframe/JTemplate.java | 2 +- .../design/mainframe/JTemplateProvider.java | 6 +- .../designer/beans/models/StateModel.java | 66 +++-- .../designer/creator/XCreatorUtils.java | 8 +- .../fr/design/mainframe/ComponentTree.java | 30 ++- .../com/fr/design/mainframe/FormDesigner.java | 8 +- .../fr/design/mainframe/FormModelAdapter.java | 187 +++++++------- .../java/com/fr/design/mainframe/JForm.java | 4 +- .../actions/report/ReportParameterAction.java | 22 +- .../fr/design/mainframe/ElementCasePane.java | 1 + .../com/fr/design/mainframe/JWorkBook.java | 11 +- .../mainframe/WorkBookModelAdapter.java | 244 +++++++++--------- 17 files changed, 480 insertions(+), 305 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java index 251ee7af8..4ebc64103 100644 --- a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java +++ b/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 + *

+ * 指的是编辑的模板是普通报表还是决策报表 * * @author zhou * @since 2012-7-26上午11:24:54 */ -public abstract class DesignModelAdapter { +public abstract class DesignModelAdapter> { + /** + * 当前的设计模式 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]; } + /** + * 获取编辑模板的所有参数 + *

+ * 由于在参数面板拖动过程中频繁获取 + * 远程设计时数据集参数rpc 调用需要考虑网络等因素,因此会比较缓慢,引起参数面板拖动卡顿, + * 所以缓存一下,并且在参数改动时及时缓存 + * + * @return Parameter[] 模板的所有参数 + */ public Parameter[] getParameters() { - return new Parameter[0]; + return parameters == null ? new Parameter[0] : parameters; } - // 报表参数 + /** + * 模板参数(报表参数) + *

+ * 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存 + * + * @return Parameter[] 模板参数 + * @deprecated use {@link DesignModelAdapter#getTemplateParameters()} instead + */ + @Deprecated public Parameter[] getReportParameters() { - return new Parameter[0]; + return getTableDataParameters(); + } + + /** + * 模板参数(报表参数) + *

+ * 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存 + * + * @return Parameter[] 模板参数 + */ + public Parameter[] getTemplateParameters() { + return templateParameters == null ? new Parameter[0] : templateParameters; } /** * 数据源参数 + *

+ * 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存 * - * @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 getWidgetsName(); + /** + * 更新缓存的参数 + */ + public void updateCachedParameter() { + // 全部参数 + this.parameters = getLatestParameters(); + // 数据及参数 + this.tableDataParameters = getLatestTableDataParameters(); + // 模板参数 + this.templateParameters = getLatestTemplateParameters(); + + } + /** * 环境改变. */ @@ -146,4 +241,19 @@ public abstract class DesignModelAdapter extends JComponent { +public abstract class TargetComponent extends JComponent implements JTemplateProvider { private T target; public TargetComponent(T t) { @@ -34,6 +35,7 @@ public abstract class TargetComponent extends JComponent { public abstract void stopEditing(); + @Override public T getTarget() { return target; } @@ -82,6 +84,7 @@ public abstract class TargetComponent extends JComponent { /** * Fire template modified listeners. */ + @Override public void fireTargetModified() { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index b73805ee6..e4bd1db95 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/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.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; @@ -99,6 +100,10 @@ public class HistoryTemplateListCache implements CallbackEvent { return this.editingTemplate; } + /** + * @param jt jt + * @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate) + */ public void setCurrentEditingTemplate(JTemplate jt) { this.editingTemplate = jt; //如果当前历史面板中没有 diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java index a51735f64..2dc56cc9d 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java +++ b/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); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java b/designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java index 559387b20..d3cff1ff9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java +++ b/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 extends JTemplateProvider { String XML_TAG = "JForm"; int FORM_TAB = 0; @@ -32,11 +32,6 @@ public interface BaseJForm extends JTemplateProvider { */ void refreshSelectedWidget(); - /** - * 获取当前的Target - */ - Object getTarget(); - /** * 执行撤销 * diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 7b80c3fd7..7f5cab744 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -75,7 +75,7 @@ import java.util.regex.Pattern; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ -public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, JTemplateProvider, DesignerProxy { +public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null private static final int PREFIX_NUM = 3000; private FILE editingFILE = null; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java index 7df132d6e..fb87f7f04 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java +++ b/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 { - public void fireTargetModified(); + void fireTargetModified(); + + T getTarget(); } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java index 5eee1aca8..1e7badb8a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java +++ b/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; } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 748c37783..774010136 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/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(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 02abef010..a2f295f87 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/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)); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index fd0de4b25..5dd42de8d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/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.stable.ArrayUtils; import com.fr.stable.bridge.StableFactory; +import com.fr.third.javax.annotation.Nullable; import javax.swing.Action; import javax.swing.JComponent; @@ -918,7 +919,7 @@ public class FormDesigner extends TargetComponent

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所发生的位置相对根组件的位置关系 @@ -980,6 +981,7 @@ public class FormDesigner extends TargetComponent 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, @@ -1191,8 +1193,10 @@ public class FormDesigner extends TargetComponent implements TreeSelection } return designerActions.toArray(new UpdateAction[designerActions.size()]); } + /** * 扩展菜单项 + * * @param actions */ public void dmlActions(List actions) { @@ -1200,7 +1204,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection Set selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG); for (RightSelectionHandlerProvider handler : selectionHandlerProviders) { if (handler.accept(this)) { - handler.dmlUpdateActions(this,actions); + handler.dmlUpdateActions(this, actions); } } } catch (Exception e) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java index 3c1233fab..670c2fa48 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java +++ b/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 { +public class FormModelAdapter extends DesignModelAdapter> { - public FormModelAdapter(BaseJForm jForm) { - super(jForm); - } + public FormModelAdapter(BaseJForm 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 { * @param newName 新名字. * @return 返回是否名字一样. */ - public boolean renameTableData(String oldName, String newName) { - if (super.renameTableData(oldName, newName)) { - jTemplate.refreshSelectedWidget(); - return true; - } - return false; - } - - @Override - public List getWidgetsName() { - final List list = new ArrayList(); - 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 linkAbleList = new ArrayList(); + public boolean renameTableData(String oldName, String newName) { + if (super.renameTableData(oldName, newName)) { + jTemplate.refreshSelectedWidget(); + return true; + } + return false; + } + + @Override + public List getWidgetsName() { + final List list = new ArrayList(); + 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 linkAbleList = new ArrayList(); 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 list = new java.util.ArrayList(); - java.util.Iterator 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 list = new java.util.ArrayList(); + java.util.Iterator 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(); + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index cc3ba96f5..06f763226 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -86,7 +86,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class JForm extends JTemplate implements BaseJForm { +public class JForm extends JTemplate implements BaseJForm { private static final String FORM_CARD = "FORM"; private static final String ELEMENTCASE_CARD = "ELEMENTCASE"; @@ -139,7 +139,7 @@ public class JForm extends JTemplate implements BaseJForm { return DesignState.JFORM; } - public TemplateProcessInfo getProcessInfo() { + public TemplateProcessInfo getProcessInfo() { if (processInfo == null) { processInfo = new JFormProcessInfo(template); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java index 5a72fd13c..1d044909c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportParameterAction.java +++ b/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); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index 4112ac6c4..5bc5cd791 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -862,6 +862,7 @@ public abstract class ElementCasePane extends Tar /** * 响应目标变动. */ + @Override public void fireTargetModified() { // marks:自动计算 TemplateElementCase report = this.getEditingElementCase(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 569f02bb6..58ecb1ea8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -204,7 +204,7 @@ public class JWorkBook extends JTemplate { } @Override - public TemplateProcessInfo getProcessInfo() { + public TemplateProcessInfo getProcessInfo() { if (processInfo == null) { processInfo = new JWorkBookProcessInfo(template); } @@ -309,10 +309,10 @@ public class JWorkBook extends JTemplate { 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 { // //////////////////////OLD BELOW///////////////////////// // //////////////////////////////////////////////////////// - @Override + /** * set target */ + @Override public void setTarget(WorkBook book) { if (book == null) { return; @@ -1098,7 +1099,7 @@ public class JWorkBook extends JTemplate { FILE newFile = createNewEmptyFile(); //如果文件已经打开, 那么就覆盖关闭掉他 MutilTempalteTabPane.getInstance().closeFileTemplate(newFile); - final TemplateWorkBook tpl = this.getTarget(); + final WorkBook tpl = this.getTarget(); // 弹出输入参数 java.util.Map parameterMap = inputParameters(tpl); @@ -1106,7 +1107,7 @@ public class JWorkBook extends JTemplate { 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()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java index d84090b18..1e55d3c9b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java +++ b/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 { - 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 list = new java.util.ArrayList(); - java.util.Iterator 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 getWidgetsName() { - List list = new ArrayList(); - 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 nameList = new ArrayList(); - Iterator 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 list = new java.util.ArrayList(); + java.util.Iterator 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 getWidgetsName() { + List list = new ArrayList(); + 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 nameList = new ArrayList(); + Iterator it = elementCase.floatIterator(); + while (it.hasNext()) { + nameList.add(it.next().getName()); + } + return nameList.toArray(new String[nameList.size()]); + } public Widget[] getLinkableWidgets() { From a515a01364cc684cba27e8814b8ee977214f5488 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 13 Dec 2018 09:42:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-12885=20=E9=83=A8=E5=88=86=E7=94=B5?= =?UTF-8?q?=E8=84=91=E5=9C=A8=E7=BD=91=E7=BB=9C=E7=95=85=E9=80=9A=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B3=E7=A7=92=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-realize/src/main/java/com/fr/start/SplashContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/start/SplashContext.java b/designer-realize/src/main/java/com/fr/start/SplashContext.java index 2e5467557..a8a542a58 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/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(); From 2c50f3d1dd33482648882b64543c3c4b895d9531 Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Fri, 14 Dec 2018 15:52:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-13431=20=E5=8A=9F=E8=83=BD=E7=82=B9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95,=20=E9=9C=80=E8=A6=81=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=201.=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=8E=9F=E5=85=88=E6=94=B6=E9=9B=86=E5=9C=A8feedback=EF=BC=8C1?= =?UTF-8?q?0.0=E9=9C=80=E8=A6=81=E9=80=82=E9=85=8D=202.=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=82=B9=E4=BB=8Emetric=E5=8F=96=E6=95=B0=EF=BC=8C=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E4=BC=A0=E5=85=A5Date=E4=BB=8E12=E6=9C=8810=E5=8F=B7?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=B0=B1=E6=8B=BF=E4=B8=8D=E5=88=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BA=86=EF=BC=8C=E6=8D=A2=E7=94=A8long=E6=98=AF?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/InformationCollector.java | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 047ffc671..0398189d9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -170,7 +170,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { } - private byte[] getJSONContentAsByte(){ + private JSONObject getJSONContentAsByte(){ JSONObject content = new JSONObject(); JSONArray startStopArray = new JSONArray(); @@ -192,13 +192,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(){ @@ -208,19 +202,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 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(); @@ -236,7 +228,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { } JSONArray content = null; try { - content = getFunctionsContent(current, new Date(lastTime)); + content = getFunctionsContent(currentTime, lastTime); } catch (JSONException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -451,7 +443,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { }); } - public static JSONArray getFunctionsContent(Date current, Date last) throws JSONException{ + public static JSONArray getFunctionsContent(long current, long last) throws JSONException{ //记录当前条数,达到200条合并成一个请求 int count = 0; JSONArray functionArray = new JSONArray();