FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/app/src/processing/app/ui/ErrorTable.java at master · 2php/processing · GitHub
2php
processing
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
ui
/
ErrorTable.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
243 lines (195 loc) · 7.59 KB
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
ui
/
ErrorTable.java
Copy path
File metadata and controls
243 lines (195 loc) · 7.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012-15 The Processing Foundation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
processing
.
app
.
ui
;
import
java
.
awt
.
Color
;
import
java
.
awt
.
Component
;
import
java
.
awt
.
Dimension
;
import
java
.
awt
.
Font
;
import
java
.
awt
.
event
.
MouseAdapter
;
import
java
.
awt
.
event
.
MouseEvent
;
import
javax
.
swing
.
JLabel
;
import
javax
.
swing
.
JTable
;
import
javax
.
swing
.
ListSelectionModel
;
import
javax
.
swing
.
SwingConstants
;
import
javax
.
swing
.
ToolTipManager
;
import
javax
.
swing
.
table
.
DefaultTableModel
;
import
javax
.
swing
.
table
.
JTableHeader
;
import
javax
.
swing
.
table
.
TableCellRenderer
;
import
javax
.
swing
.
table
.
TableColumn
;
import
processing
.
app
.
Language
;
import
processing
.
app
.
Mode
;
import
processing
.
app
.
ui
.
Editor
;
public
class
ErrorTable
extends
JTable
{
Editor
editor
;
public
interface
Entry
{
public
boolean
isError
();
public
boolean
isWarning
();
}
static
final
String
[]
columnNames
= {
""
,
// the blank column used for spacing
Language
.
text
(
"editor.footer.errors.problem"
),
Language
.
text
(
"editor.footer.errors.tab"
),
Language
.
text
(
"editor.footer.errors.line"
)
};
static
final
int
DATA_COLUMN
=
0
;
static
final
int
PROBLEM_COLUMN
=
1
;
static
final
int
TAB_COLUMN
=
2
;
static
final
int
LINE_COLUMN
=
3
;
Font
headerFont
;
Color
headerColor
;
Color
headerBgColor
;
Font
rowFont
;
Color
rowColor
;
Color
rowBgColor
;
public
ErrorTable
(
final
Editor
editor
) {
super
(
new
DefaultTableModel
(
columnNames
,
0
));
setSelectionMode
(
ListSelectionModel
.
SINGLE_SELECTION
);
this
.
editor
=
editor
;
JTableHeader
header
=
getTableHeader
();
Mode
mode
=
editor
.
getMode
();
header
.
setDefaultRenderer
(
new
GradyHeaderRenderer
(
mode
));
setDefaultRenderer
(
Object
.
class
,
new
GradyRowRenderer
(
mode
));
//setShowGrid(false);
setIntercellSpacing
(
new
Dimension
(
0
,
0
));
// be specific about the width of the first column
TableColumn
emptyColumn
=
columnModel
.
getColumn
(
0
);
emptyColumn
.
setMaxWidth
(
Editor
.
LEFT_GUTTER
);
emptyColumn
.
setMinWidth
(
Editor
.
LEFT_GUTTER
);
columnModel
.
getColumn
(
PROBLEM_COLUMN
).
setPreferredWidth
(
400
);
columnModel
.
getColumn
(
TAB_COLUMN
).
setPreferredWidth
(
100
);
columnModel
.
getColumn
(
LINE_COLUMN
).
setPreferredWidth
(
50
);
// // the other columns are just a preference
// for (int i = 1; i < columnModel.getColumnCount(); i++) {
// columnModel.getColumn(i).setPreferredWidth(columnWidths[i]);
// }
addMouseListener
(
new
MouseAdapter
() {
@
Override
synchronized
public
void
mouseClicked
(
MouseEvent
e
) {
try
{
int
row
= ((
ErrorTable
)
e
.
getSource
()).
getSelectedRow
();
if
(
row
>=
0
&&
row
<
getRowCount
()) {
Object
data
=
getModel
().
getValueAt
(
row
,
DATA_COLUMN
);
int
clickCount
=
e
.
getClickCount
();
if
(
clickCount
==
1
) {
editor
.
errorTableClick
(
data
);
}
else
if
(
clickCount
>
1
) {
editor
.
errorTableDoubleClick
(
data
);
}
editor
.
getTextArea
().
requestFocusInWindow
();
// editor.getErrorChecker().scrollToErrorLine(row);
}
}
catch
(
Exception
ex
) {
ex
.
printStackTrace
();
}
}
});
header
.
setReorderingAllowed
(
false
);
ToolTipManager
.
sharedInstance
().
registerComponent
(
this
);
}
public
void
clearRows
() {
DefaultTableModel
dtm
= (
DefaultTableModel
)
getModel
();
dtm
.
setRowCount
(
0
);
}
public
void
addRow
(
Entry
data
,
String
message
,
String
filename
,
String
line
) {
DefaultTableModel
dtm
= (
DefaultTableModel
)
getModel
();
dtm
.
addRow
(
new
Object
[] {
data
,
message
,
filename
,
line
});
}
@
Override
public
boolean
isCellEditable
(
int
rowIndex
,
int
colIndex
) {
return
false
;
// Disallow the editing of any cell
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
static
class
GradyHeaderRenderer
extends
JLabel
implements
TableCellRenderer
{
public
GradyHeaderRenderer
(
Mode
mode
) {
setFont
(
mode
.
getFont
(
"errors.header.font"
));
setAlignmentX
(
LEFT_ALIGNMENT
);
setForeground
(
mode
.
getColor
(
"errors.header.fgcolor"
));
setBackground
(
mode
.
getColor
(
"errors.header.bgcolor"
));
setOpaque
(
true
);
}
@
Override
public
Component
getTableCellRendererComponent
(
JTable
table
,
Object
value
,
boolean
selected
,
boolean
focused
,
int
row
,
int
column
) {
setText
(
value
==
null
?
""
:
value
.
toString
());
return
this
;
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
static
class
GradyRowRenderer
extends
JLabel
implements
TableCellRenderer
{
Color
textColor
;
Color
bgColor
;
Color
textColorSelected
;
Color
bgColorSelected
;
Color
bgColorError
;
Color
bgColorWarning
;
// int indicatorSize;
Color
errorIndicatorColor
;
Color
warningIndicatorColor
;
public
GradyRowRenderer
(
Mode
mode
) {
setFont
(
mode
.
getFont
(
"errors.row.font"
));
setAlignmentX
(
LEFT_ALIGNMENT
);
textColor
=
mode
.
getColor
(
"errors.row.fgcolor"
);
bgColor
=
mode
.
getColor
(
"errors.row.bgcolor"
);
textColorSelected
=
mode
.
getColor
(
"errors.selection.fgcolor"
);
bgColorSelected
=
mode
.
getColor
(
"errors.selection.bgcolor"
);
bgColorError
=
mode
.
getColor
(
"errors.selection.error.bgcolor"
);
bgColorWarning
=
mode
.
getColor
(
"errors.selection.warning.bgcolor"
);
// indicatorSize = mode.getInteger("errors.indicator.size");
errorIndicatorColor
=
mode
.
getColor
(
"errors.indicator.error.color"
);
warningIndicatorColor
=
mode
.
getColor
(
"errors.indicator.warning.color"
);
setOpaque
(
true
);
}
@
Override
public
Component
getTableCellRendererComponent
(
JTable
table
,
Object
value
,
boolean
selected
,
boolean
focused
,
int
row
,
int
column
) {
Entry
entry
= (
Entry
)
table
.
getValueAt
(
row
,
DATA_COLUMN
);
if
(
selected
) {
setForeground
(
textColorSelected
);
if
(
entry
.
isError
()) {
setBackground
(
bgColorError
);
}
else
if
(
entry
.
isWarning
()) {
setBackground
(
bgColorWarning
);
}
else
{
setBackground
(
bgColorSelected
);
}
}
else
{
setForeground
(
textColor
);
setBackground
(
bgColor
);
}
if
(
column
==
DATA_COLUMN
) {
setText
(
"
\u2022
"
);
setHorizontalAlignment
(
SwingConstants
.
CENTER
);
if
(
entry
.
isError
()) {
setForeground
(
errorIndicatorColor
);
}
else
if
(
entry
.
isWarning
()) {
setForeground
(
warningIndicatorColor
);
}
else
{
setText
(
""
);
// no dot
}
}
else
if
(
value
==
null
) {
setText
(
""
);
}
else
{
setHorizontalAlignment
(
SwingConstants
.
LEFT
);
setText
(
value
.
toString
());
}
return
this
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL