1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.gef;
|
12
|
|
13
|
import com.ibm.icu.text.DecimalFormat;
|
14
|
import com.ibm.icu.text.NumberFormat;
|
15
|
|
16
|
import org.eclipse.swt.widgets.Text;
|
17
|
|
18
|
/**
|
19
|
* This is an internal class used for debugging
|
20
|
*
|
21
|
* @deprecated in 3.1 This class will be removed in future releases.
|
22
|
*/
|
23
|
public final class GEF {
|
24
|
|
25
|
static final String TAB = " ";//$NON-NLS-1$
|
26
|
|
27
|
static Text text;
|
28
|
static int msgCount;
|
29
|
static int tab;
|
30
|
static NumberFormat formatter = new DecimalFormat();
|
31
|
|
32
|
/**
|
33
|
* @deprecated
|
34
|
*/
|
35
|
public static boolean DebugTools = false;
|
36
|
/**
|
37
|
* @deprecated
|
38
|
*/
|
39
|
public static boolean DebugEvents = false;
|
40
|
/**
|
41
|
* @deprecated
|
42
|
*/
|
43
|
public static boolean DebugEditParts = false;
|
44
|
/**
|
45
|
* @deprecated
|
46
|
*/
|
47
|
public static boolean DebugPainting = false;
|
48
|
/**
|
49
|
* @deprecated
|
50
|
*/
|
51
|
public static boolean DebugFeedback = false;
|
52
|
/**
|
53
|
* @deprecated
|
54
|
*/
|
55
|
public static boolean GlobalDebug = false;
|
56
|
/**
|
57
|
* @deprecated
|
58
|
*/
|
59
|
public static boolean DebugToolStates = false;
|
60
|
/**
|
61
|
* @deprecated
|
62
|
*/
|
63
|
public static boolean DebugDND = false;
|
64
|
|
65
|
/**
|
66
|
* Clears the trace console if active
|
67
|
*
|
68
|
* @since 1.0
|
69
|
*/
|
70
|
public static void clearConsole() {
|
71
|
if (text == null)
|
72
|
return;
|
73
|
text.setText("");//$NON-NLS-1$
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Sets a text control to be used as a console.
|
78
|
*
|
79
|
* @since 1.0
|
80
|
* @param textBox
|
81
|
* the text control for streaming
|
82
|
*/
|
83
|
public static void setConsole(Text textBox) {
|
84
|
msgCount = 0;
|
85
|
formatter.setMinimumIntegerDigits(2);
|
86
|
formatter.setMaximumFractionDigits(0);
|
87
|
text = textBox;
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* decrements the tracing indentation
|
92
|
*
|
93
|
* @since 2.0
|
94
|
*/
|
95
|
public static void debugPop() {
|
96
|
tab--;
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Prints the given string to a trace window and increments indentation.
|
101
|
*
|
102
|
* @since 2.0
|
103
|
* @param heading
|
104
|
* the message describing the indented text to follow
|
105
|
*/
|
106
|
public static void debugPush(String heading) {
|
107
|
debug(heading);
|
108
|
tab++;
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* Prints the given message to a trace window if available.
|
113
|
*
|
114
|
* @since 1.0
|
115
|
* @param message
|
116
|
* a debug message
|
117
|
*/
|
118
|
public static void debug(String message) {
|
119
|
String lineNumber = formatter.format(new Long(msgCount++));
|
120
|
msgCount %= 100;
|
121
|
String indent = "";//$NON-NLS-1$
|
122
|
for (int i = 0; i < tab; i++)
|
123
|
indent += TAB;
|
124
|
if (text != null)
|
125
|
text.append('\n' + lineNumber + '\t' + indent + message);
|
126
|
}
|
127
|
|
128
|
}
|