Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
5006b3e8
Commit
5006b3e8
authored
May 07, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gui: fix cell renderer in search dialog (#271)
parent
7216635d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
CommonSearchDialog.java
jadx-gui/src/main/java/jadx/gui/ui/CommonSearchDialog.java
+32
-16
No files found.
jadx-gui/src/main/java/jadx/gui/ui/CommonSearchDialog.java
View file @
5006b3e8
...
...
@@ -14,6 +14,7 @@ import java.awt.event.WindowAdapter;
import
java.awt.event.WindowEvent
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -146,7 +147,8 @@ public abstract class CommonSearchDialog extends JDialog {
ResultsTableCellRenderer
renderer
=
new
ResultsTableCellRenderer
();
resultsModel
=
new
ResultsModel
(
renderer
);
resultsModel
.
addTableModelListener
(
e
->
updateProgressLabel
());
resultsTable
=
new
ResultsTable
(
resultsModel
);
resultsTable
=
new
ResultsTable
(
resultsModel
,
renderer
);
resultsTable
.
setShowHorizontalLines
(
false
);
resultsTable
.
setDragEnabled
(
false
);
resultsTable
.
setSelectionMode
(
ListSelectionModel
.
SINGLE_SELECTION
);
...
...
@@ -154,7 +156,13 @@ public abstract class CommonSearchDialog extends JDialog {
resultsTable
.
setColumnSelectionAllowed
(
false
);
resultsTable
.
setAutoResizeMode
(
JTable
.
AUTO_RESIZE_OFF
);
resultsTable
.
setAutoscrolls
(
false
);
resultsTable
.
setDefaultRenderer
(
Object
.
class
,
renderer
);
Enumeration
<
TableColumn
>
columns
=
resultsTable
.
getColumnModel
().
getColumns
();
while
(
columns
.
hasMoreElements
())
{
TableColumn
column
=
columns
.
nextElement
();
column
.
setCellRenderer
(
renderer
);
}
resultsTable
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
...
...
@@ -192,17 +200,17 @@ public abstract class CommonSearchDialog extends JDialog {
JButton
nextPageButton
=
new
JButton
(
"->"
);
nextPageButton
.
setToolTipText
(
NLS
.
str
(
"search_dialog.next_page"
));
nextPageButton
.
addActionListener
(
e
->
{
resultsModel
.
nextPage
();
resultsTable
.
updateTable
(
);
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
if
(
resultsModel
.
nextPage
())
{
switchPage
(
renderer
);
}
});
JButton
prevPageButton
=
new
JButton
(
"<-"
);
prevPageButton
.
setToolTipText
(
NLS
.
str
(
"search_dialog.prev_page"
));
prevPageButton
.
addActionListener
(
e
->
{
resultsModel
.
prevPage
();
resultsTable
.
updateTable
(
);
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
if
(
resultsModel
.
prevPage
())
{
switchPage
(
renderer
);
}
});
paginationPanel
.
add
(
prevPageButton
);
...
...
@@ -214,6 +222,13 @@ public abstract class CommonSearchDialog extends JDialog {
return
resultsPanel
;
}
private
void
switchPage
(
ResultsTableCellRenderer
renderer
)
{
renderer
.
clear
();
resultsTable
.
updateTable
();
updateProgressLabel
();
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
}
protected
void
updateProgressLabel
()
{
String
statusText
=
String
.
format
(
NLS
.
str
(
"search_dialog.info_label"
),
...
...
@@ -226,9 +241,11 @@ public abstract class CommonSearchDialog extends JDialog {
protected
static
class
ResultsTable
extends
JTable
{
private
static
final
long
serialVersionUID
=
3901184054736618969L
;
private
final
transient
ResultsTableCellRenderer
renderer
;
public
ResultsTable
(
ResultsModel
resultsModel
)
{
public
ResultsTable
(
ResultsModel
resultsModel
,
ResultsTableCellRenderer
renderer
)
{
super
(
resultsModel
);
this
.
renderer
=
renderer
;
}
public
void
updateTable
()
{
...
...
@@ -246,7 +263,6 @@ public abstract class CommonSearchDialog extends JDialog {
for
(
int
col
=
0
;
col
<
columnCount
;
col
++)
{
int
colWidth
=
50
;
for
(
int
row
=
0
;
row
<
rowCount
;
row
++)
{
TableCellRenderer
renderer
=
getCellRenderer
(
row
,
col
);
Component
comp
=
prepareRenderer
(
renderer
,
row
,
col
);
if
(
comp
==
null
)
{
continue
;
...
...
@@ -324,20 +340,20 @@ public abstract class CommonSearchDialog extends JDialog {
return
Math
.
min
(
rows
.
size
(),
start
+
RESULTS_PER_PAGE
);
}
public
void
nextPage
()
{
public
boolean
nextPage
()
{
if
(
start
+
RESULTS_PER_PAGE
<
rows
.
size
())
{
renderer
.
clear
();
start
+=
RESULTS_PER_PAGE
;
fireTableStructureChanged
()
;
return
true
;
}
return
false
;
}
public
void
prevPage
()
{
public
boolean
prevPage
()
{
if
(
start
-
RESULTS_PER_PAGE
>=
0
)
{
renderer
.
clear
();
start
-=
RESULTS_PER_PAGE
;
fireTableStructureChanged
()
;
return
true
;
}
return
false
;
}
@Override
...
...
@@ -345,7 +361,7 @@ public abstract class CommonSearchDialog extends JDialog {
if
(
rows
.
isEmpty
())
{
return
0
;
}
return
getDisplayedResultsEnd
()
-
getDisplayedResultsStart
()
;
return
getDisplayedResultsEnd
()
-
start
;
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment