01: package net.sourceforge.tracelog.listeners;
02:
03: import org.eclipse.swt.custom.StyledText;
04:
05: public class LogSizeHandler {
06: private int lineCount;
07: private int logLineThreshold;
08: private StyledText logST;
09: private int purgePercentage;
10:
11: public LogSizeHandler(StyledText logST, int purgePercentage,
12: int threshold) {
13: this .logST = logST;
14: this .lineCount = logST.getLineCount();
15: this .purgePercentage = purgePercentage;
16: this .logLineThreshold = threshold;
17: }
18:
19: public void run() {
20: if (++lineCount > logLineThreshold) {
21: lineCount = 0;
22:
23: if (purgePercentage == 100) {
24: logST.setText("");
25: } else {
26: int maxLineToPurge = purgePercentage
27: * logST.getLineCount() / 100;
28: logST.replaceTextRange(0, logST
29: .getOffsetAtLine(maxLineToPurge), "");
30: }
31: }
32: }
33: }
|