diff --git a/designer/src/com/fr/aspectj/designer/TemplateProcessTracker.aj b/designer/src/com/fr/aspectj/designer/TemplateProcessTracker.aj new file mode 100644 index 000000000..a2c3565d9 --- /dev/null +++ b/designer/src/com/fr/aspectj/designer/TemplateProcessTracker.aj @@ -0,0 +1,73 @@ +package com.fr.aspectj.designer; + +/** + * 记录模板过程 + * Created by plough on 2017/3/3. + */ + +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; +import org.aspectj.lang.reflect.SourceLocation; + +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.util.Date; + +public aspect TemplateProcessTracker { + //声明一个pointcut,匹配你需要的方法 + pointcut onMouseClicked(MouseEvent e) : + execution(* mouseClicked(MouseEvent)) && args(e); + pointcut onMousePressed(MouseEvent e) : + execution(* mousePressed(MouseEvent)) && args(e); + pointcut onMouseReleased(MouseEvent e) : + execution(* mouseReleased(MouseEvent)) && args(e); + pointcut onActionPerformed(ActionEvent e) : + execution(* actionPerformed(ActionEvent)) && args(e); + pointcut onSetValueAt(Object v, int r, int c) : + execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c); + pointcut onSetValue4EditingElement(Object v) : + execution(* setValue4EditingElement(java.lang.Object)) && args(v); + + //before表示之前的意思 + //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 + before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + } + //同上 + before(ActionEvent e) : onActionPerformed(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 + if (e.getSource().toString().contains("javax.swing.Timer")) { + return; + } + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + + } + //同上 + before(Object v, int r, int c) : onSetValueAt(v, r, c) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 +// if (e.getSource().toString().contains("javax.swing.Timer")) { +// return; +// } + + String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); + TemplateInfoCollector.appendProcess(log); + + } + //同上 + before(Object v) : onSetValue4EditingElement(v) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + +// String v = "test"; + String log = String.format("%s:\n%s\nset value: %s\n\n", new Date(), sl, v); + TemplateInfoCollector.appendProcess(log); + + } + + +} diff --git a/designer/src/com/fr/grid/Grid.java b/designer/src/com/fr/grid/Grid.java index a259cf63b..432ea888c 100644 --- a/designer/src/com/fr/grid/Grid.java +++ b/designer/src/com/fr/grid/Grid.java @@ -10,6 +10,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.fun.GridUIProcessor; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.grid.event.CellEditorEvent; @@ -35,6 +36,7 @@ import javax.swing.plaf.ComponentUI; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Point2D; +import java.util.Date; import java.util.Hashtable; import java.util.Iterator; @@ -1072,6 +1074,8 @@ public class Grid extends BaseGridComponent { * @return true if the value changed */ private boolean setValue4EditingElement(Object newValue) { + String log = String.format("%s:\nGrid.java\nset value: %s at %s\n\n", new Date(), newValue, editingCellElement); + TemplateInfoCollector.appendProcess(log); if (newValue instanceof TemplateCellElement) { TemplateCellElement cellElement = (TemplateCellElement) newValue; editingCellElement.setValue(cellElement.getValue()); diff --git a/designer_base/src/com/fr/aspectj/designerbase/TemplateProcessTracker.aj b/designer_base/src/com/fr/aspectj/designerbase/TemplateProcessTracker.aj new file mode 100644 index 000000000..04e3fa2e4 --- /dev/null +++ b/designer_base/src/com/fr/aspectj/designerbase/TemplateProcessTracker.aj @@ -0,0 +1,61 @@ +package com.fr.aspectj.designerbase; + +/** + * 记录模板过程 + * Created by plough on 2017/3/3. + */ + +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; +import org.aspectj.lang.reflect.SourceLocation; + +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.util.Date; + +public aspect TemplateProcessTracker { + //声明一个pointcut,匹配你需要的方法 + pointcut onMouseClicked(MouseEvent e) : + execution(* mouseClicked(MouseEvent)) && args(e); + pointcut onMousePressed(MouseEvent e) : + execution(* mousePressed(MouseEvent)) && args(e); + pointcut onMouseReleased(MouseEvent e) : + execution(* mouseReleased(MouseEvent)) && args(e); + pointcut onActionPerformed(ActionEvent e) : + execution(* actionPerformed(ActionEvent)) && args(e); + pointcut onSetValueAt(Object v, int r, int c) : + execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c); + + //before表示之前的意思 + //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 + before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + } + //同上 + before(ActionEvent e) : onActionPerformed(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 + if (e.getSource().toString().contains("javax.swing.Timer")) { + return; + } + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + + } + //同上 + before(Object v, int r, int c) : onSetValueAt(v, r, c) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 +// if (e.getSource().toString().contains("javax.swing.Timer")) { +// return; +// } + + String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); + TemplateInfoCollector.appendProcess(log); + } + + +} diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java index 3103f6850..a4ddba1f7 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java @@ -96,6 +96,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane> ex private PreviewProvider previewType; private long openTime = 0L; // 打开模板的时间点(包括新建模板) private TemplateInfoCollector tic = TemplateInfoCollector.getInstance(); + private StringBuilder process = new StringBuilder(""); // 制作模板的过程 public JTemplate(T t, String defaultFileName) { this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); @@ -102,6 +103,7 @@ public abstract class JTemplate> ex // 如果不是新建模板,并且在收集列表中 if (!isNewFile && tic.inList(t)) { openTime = System.currentTimeMillis(); + process.append(tic.loadProcess(t)); } } @@ -131,6 +133,16 @@ public abstract class JTemplate> ex // 获取模板控件数 public abstract int getWidgetCount(); + // 追加过程记录 + public void appendProcess(String s) { + process.append(s); + } + + // 获取过程记录 + public String getProcess() { + return process.toString(); + } + public U getUndoState() { return undoState; } diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 52542e14d..95ced6330 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.templateinfo; import com.fr.base.io.IOFile; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; @@ -49,6 +50,22 @@ public class TemplateInfoCollector implements Serializable { return instance; } + public static void appendProcess(String log) { +// System.out.println(log); + // 获取当前编辑的模板 + JTemplate jt = DesignerContext.getDesignerFrame().getSelectedJTemplate(); + // 追加过程记录 + jt.appendProcess(log); + } + + /** + * 加载已经存储的模板过程 + */ + public String loadProcess(T t) { +// return ""; + return (String)templateInfoList.get(t.getReportletsid()).get("process"); + } + /** * 根据模板ID是否在收集列表中,判断是否需要收集当前模板的信息 */ @@ -106,17 +123,18 @@ public class TemplateInfoCollector implements Serializable { } long timeConsume = saveTime - openTime; - // 如果已存有数据,则加上本次编辑时间 + // 如果已存有数据,则加上之前的累计编辑时间 if (templateInfo.get("time_consume") != null) { timeConsume += (long)templateInfo.get("time_consume"); } -// String process; + String process = jt.getProcess(); int cellCount = jt.getCellCount(); int floatCount = jt.getFloatCount(); int blockCount = jt.getBlockCount(); int widgetCount = jt.getWidgetCount(); templateInfo.put("time_consume", timeConsume); + templateInfo.put("process", process); templateInfo.put("cell_count", cellCount); templateInfo.put("float_count", floatCount); templateInfo.put("block_count", blockCount); diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessTracker.aj b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessTracker.aj new file mode 100644 index 000000000..d186f8298 --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessTracker.aj @@ -0,0 +1,71 @@ +//package com.fr.design.mainframe.templateinfo; +// +//import org.aspectj.lang.reflect.SourceLocation; +// +//import java.awt.event.ActionEvent; +//import java.awt.event.MouseEvent; +//import java.util.Date; +// +///** +// * 记录模板过程 +// * Created by plough on 2017/2/27. +// */ +//public aspect TemplateProcessTracker { +// //声明一个pointcut,匹配你需要的方法 +// pointcut onMouseClicked(MouseEvent e) : +// execution(* mouseClicked(MouseEvent)) && args(e); +// pointcut onMousePressed(MouseEvent e) : +// execution(* mousePressed(MouseEvent)) && args(e); +// pointcut onMouseReleased(MouseEvent e) : +// execution(* mouseReleased(MouseEvent)) && args(e); +// pointcut onActionPerformed(ActionEvent e) : +// execution(* actionPerformed(ActionEvent)) && args(e); +// pointcut onSetValueAt(Object v, int r, int c) : +// execution(* setValueAt(Object, int, int)) && args(v, r, c); +// pointcut onSetValue4EditingElement(Object v) : +// execution(* setValue4EditingElement(Object)) && args(v); +// +// //before表示之前的意思 +// //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 +// before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { +// SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 +// +// String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); +// TemplateInfoCollector.appendProcess(log); +// } +// //同上 +// before(ActionEvent e) : onActionPerformed(e) { +// SourceLocation sl = thisJoinPoint.getSourceLocation(); +// // !within(LogHandlerBar) 没用, 手动过滤 +// if (e.getSource().toString().contains("javax.swing.Timer")) { +// return; +// } +// +// String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); +// TemplateInfoCollector.appendProcess(log); +// +// } +// //同上 +// before(Object v, int r, int c) : onSetValueAt(v, r, c) { +// SourceLocation sl = thisJoinPoint.getSourceLocation(); +// // !within(LogHandlerBar) 没用, 手动过滤 +//// if (e.getSource().toString().contains("javax.swing.Timer")) { +//// return; +//// } +// +// String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); +// TemplateInfoCollector.appendProcess(log); +// +// } +// //同上 +// before(Object v) : onSetValue4EditingElement(v) { +// SourceLocation sl = thisJoinPoint.getSourceLocation(); +// +//// String v = "test"; +// String log = String.format("%s:\n%s\nset value: %s\n\n", new Date(), sl, v); +// TemplateInfoCollector.appendProcess(log); +// +// } +// +// +//} diff --git a/designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj b/designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj new file mode 100644 index 000000000..c192a190d --- /dev/null +++ b/designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj @@ -0,0 +1,56 @@ +package com.fr.aspectj.designerchart; + +/** + * Created by plough on 2017/3/3. + */ +import com.fr.chart.chartattr.Chart; +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; +import org.aspectj.lang.reflect.SourceLocation; + +import javax.swing.event.ListSelectionEvent; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.util.Date; + +public aspect TemplateProcessTracker { + //声明一个pointcut,匹配你需要的方法 + pointcut onMouseClicked(MouseEvent e) : + execution(* mouseClicked(MouseEvent)) && args(e); + pointcut onMousePressed(MouseEvent e) : + execution(* mousePressed(MouseEvent)) && args(e); + pointcut onMouseReleased(MouseEvent e) : + execution(* mouseReleased(MouseEvent)) && args(e); + pointcut onActionPerformed(ActionEvent e) : + execution(* actionPerformed(ActionEvent)) && args(e); + pointcut onChartUpdate(Chart c) : + execution(* update(Chart)) && args(c); + + //before表示之前的意思 + //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 + before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + } + //同上 + before(ActionEvent e) : onActionPerformed(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 + if (e.getSource().toString().contains("javax.swing.Timer")) { + return; + } + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + + } + //同上 + before(Chart c) : onChartUpdate(c) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + String log = String.format("%s:\n%s\n插入新图表:%s\n\n", new Date(), sl, c.getChartName()); + TemplateInfoCollector.appendProcess(log); + + } + +} diff --git a/designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj b/designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj new file mode 100644 index 000000000..885d21ecd --- /dev/null +++ b/designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj @@ -0,0 +1,60 @@ +package com.fr.aspectj.designerform; + +/** + * Created by plough on 2017/3/3. + */ +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; +import org.aspectj.lang.reflect.SourceLocation; + +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.util.Date; + +public aspect TemplateProcessTracker { + //声明一个pointcut,匹配你需要的方法 + pointcut onMouseClicked(MouseEvent e) : + execution(* mouseClicked(MouseEvent)) && args(e); + pointcut onMousePressed(MouseEvent e) : + execution(* mousePressed(MouseEvent)) && args(e); + pointcut onMouseReleased(MouseEvent e) : + execution(* mouseReleased(MouseEvent)) && args(e); + pointcut onActionPerformed(ActionEvent e) : + execution(* actionPerformed(ActionEvent)) && args(e); + pointcut onSetValueAt(Object v, int r, int c) : + execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c); + + //before表示之前的意思 + //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码 + before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置 + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + } + //同上 + before(ActionEvent e) : onActionPerformed(e) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 + if (e.getSource().toString().contains("javax.swing.Timer")) { + return; + } + + String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource()); + TemplateInfoCollector.appendProcess(log); + + } + //同上 + before(Object v, int r, int c) : onSetValueAt(v, r, c) { + SourceLocation sl = thisJoinPoint.getSourceLocation(); + // !within(LogHandlerBar) 没用, 手动过滤 +// if (e.getSource().toString().contains("javax.swing.Timer")) { +// return; +// } + + String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c); + TemplateInfoCollector.appendProcess(log); + + } + + +}