Browse Source

REPORT-1916 做模板的过程和耗时收集=》完成所有信息的本地存取

master
plough 8 years ago
parent
commit
da8587f2c5
  1. 73
      designer/src/com/fr/aspectj/designer/TemplateProcessTracker.aj
  2. 4
      designer/src/com/fr/grid/Grid.java
  3. 61
      designer_base/src/com/fr/aspectj/designerbase/TemplateProcessTracker.aj
  4. 1
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java
  5. 12
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  6. 22
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  7. 71
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateProcessTracker.aj
  8. 56
      designer_chart/src/com/fr/aspectj/designerchart/TemplateProcessTracker.aj
  9. 60
      designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj

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

4
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());

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

1
designer_base/src/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java

@ -96,6 +96,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa
selectedChanged();
}
});
dataJTable.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
selectedChanged();

12
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -79,6 +79,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> 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<T extends IOFile, U extends BaseUndoState<?>> ex
// 如果不是新建模板,并且在收集列表中
if (!isNewFile && tic.inList(t)) {
openTime = System.currentTimeMillis();
process.append(tic.loadProcess(t));
}
}
@ -131,6 +133,16 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
// 获取模板控件数
public abstract int getWidgetCount();
// 追加过程记录
public void appendProcess(String s) {
process.append(s);
}
// 获取过程记录
public String getProcess() {
return process.toString();
}
public U getUndoState() {
return undoState;
}

22
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<T extends IOFile> 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<T extends IOFile> 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);

71
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);
//
// }
//
//
//}

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

60
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);
}
}
Loading…
Cancel
Save