Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Autopsy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Autopsy
Commits
f59276ec
Commit
f59276ec
authored
7 years ago
by
Richard Cordovano
Browse files
Options
Downloads
Plain Diff
Merge branch 'release-4.4.1' of github.com:sleuthkit/autopsy into release-4.4.1
parents
ed9316cc
8554af8e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerArtifact.java
+97
-4
97 additions, 4 deletions
...kit/autopsy/corecomponents/DataContentViewerArtifact.java
with
97 additions
and
4 deletions
Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerArtifact.java
+
97
−
4
View file @
f59276ec
...
@@ -32,8 +32,14 @@
...
@@ -32,8 +32,14 @@
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
javax.swing.JMenuItem
;
import
javax.swing.JMenuItem
;
import
javax.swing.SwingWorker
;
import
javax.swing.SwingWorker
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ListSelectionEvent
;
import
javax.swing.event.TableColumnModelEvent
;
import
javax.swing.table.DefaultTableModel
;
import
javax.swing.table.DefaultTableModel
;
import
javax.swing.table.TableColumn
;
import
javax.swing.table.TableColumn
;
import
javax.swing.event.TableColumnModelListener
;
import
javax.swing.text.JTextComponent
;
import
javax.swing.text.View
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.openide.nodes.Node
;
import
org.openide.nodes.Node
;
import
org.openide.util.Lookup
;
import
org.openide.util.Lookup
;
...
@@ -52,8 +58,8 @@
...
@@ -52,8 +58,8 @@
/**
/**
* Instances of this class display the BlackboardArtifacts associated with the
* Instances of this class display the BlackboardArtifacts associated with the
* Content represented by a Node. Each BlackboardArtifact is rendered displayed
in a JTable
* Content represented by a Node. Each BlackboardArtifact is rendered displayed
* representation of its BlackboardAttributes.
*
in a JTable
representation of its BlackboardAttributes.
*/
*/
@ServiceProvider
(
service
=
DataContentViewer
.
class
,
position
=
3
)
@ServiceProvider
(
service
=
DataContentViewer
.
class
,
position
=
3
)
public
class
DataContentViewerArtifact
extends
javax
.
swing
.
JPanel
implements
DataContentViewer
{
public
class
DataContentViewerArtifact
extends
javax
.
swing
.
JPanel
implements
DataContentViewer
{
...
@@ -78,6 +84,7 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
...
@@ -78,6 +84,7 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
Bundle
.
DataContentViewerArtifact_attrsTableHeader_value
(),
Bundle
.
DataContentViewerArtifact_attrsTableHeader_value
(),
Bundle
.
DataContentViewerArtifact_attrsTableHeader_sources
()};
Bundle
.
DataContentViewerArtifact_attrsTableHeader_sources
()};
private
static
final
int
[]
COLUMN_WIDTHS
=
{
100
,
800
,
100
};
private
static
final
int
[]
COLUMN_WIDTHS
=
{
100
,
800
,
100
};
private
static
final
int
CELL_BOTTOM_MARGIN
=
5
;
public
DataContentViewerArtifact
()
{
public
DataContentViewerArtifact
()
{
initResultsTable
();
initResultsTable
();
...
@@ -85,6 +92,7 @@ public DataContentViewerArtifact() {
...
@@ -85,6 +92,7 @@ public DataContentViewerArtifact() {
resultsTableScrollPane
.
setViewportView
(
resultsTable
);
resultsTableScrollPane
.
setViewportView
(
resultsTable
);
customizeComponents
();
customizeComponents
();
resetComponents
();
resetComponents
();
resultsTable
.
setDefaultRenderer
(
Object
.
class
,
new
MultiLineTableCellRenderer
());
}
}
private
void
initResultsTable
()
{
private
void
initResultsTable
()
{
...
@@ -100,11 +108,71 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
...
@@ -100,11 +108,71 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
resultsTable
.
getTableHeader
().
setReorderingAllowed
(
false
);
resultsTable
.
getTableHeader
().
setReorderingAllowed
(
false
);
resultsTable
.
setColumnHidingAllowed
(
false
);
resultsTable
.
setColumnHidingAllowed
(
false
);
resultsTable
.
getColumnModel
().
getSelectionModel
().
setSelectionMode
(
javax
.
swing
.
ListSelectionModel
.
SINGLE_INTERVAL_SELECTION
);
resultsTable
.
getColumnModel
().
getSelectionModel
().
setSelectionMode
(
javax
.
swing
.
ListSelectionModel
.
SINGLE_INTERVAL_SELECTION
);
updateColumnSizes
();
resultsTable
.
getColumnModel
().
addColumnModelListener
(
new
TableColumnModelListener
()
{
@Override
public
void
columnAdded
(
TableColumnModelEvent
e
)
{
}
@Override
public
void
columnRemoved
(
TableColumnModelEvent
e
)
{
}
@Override
public
void
columnMoved
(
TableColumnModelEvent
e
)
{
}
@Override
public
void
columnMarginChanged
(
ChangeEvent
e
)
{
updateRowHeights
();
//When the user changes column width we may need to resize row height
}
@Override
public
void
columnSelectionChanged
(
ListSelectionEvent
e
)
{
}
});
resultsTable
.
setAutoResizeMode
(
javax
.
swing
.
JTable
.
AUTO_RESIZE_NEXT_COLUMN
);
}
/**
* Sets the row heights to the heights of the content in their Value column.
*/
private
void
updateRowHeights
()
{
int
valueColIndex
=
-
1
;
for
(
int
col
=
0
;
col
<
resultsTable
.
getColumnCount
();
col
++)
{
if
(
resultsTable
.
getColumnName
(
col
).
equals
(
COLUMN_HEADERS
[
1
]))
{
valueColIndex
=
col
;
}
}
if
(
valueColIndex
!=
-
1
)
{
for
(
int
row
=
0
;
row
<
resultsTable
.
getRowCount
();
row
++)
{
Component
comp
=
resultsTable
.
prepareRenderer
(
resultsTable
.
getCellRenderer
(
row
,
valueColIndex
),
row
,
valueColIndex
);
final
int
rowHeight
;
if
(
comp
instanceof
JTextComponent
)
{
final
JTextComponent
tc
=
(
JTextComponent
)
comp
;
final
View
rootView
=
tc
.
getUI
().
getRootView
(
tc
);
java
.
awt
.
Insets
i
=
tc
.
getInsets
(
null
);
rootView
.
setSize
(
resultsTable
.
getColumnModel
().
getColumn
(
valueColIndex
)
.
getPreferredWidth
()
-
i
.
left
-
i
.
right
,
Integer
.
MAX_VALUE
);
rowHeight
=
(
int
)
rootView
.
getPreferredSpan
(
View
.
Y_AXIS
);
}
else
{
rowHeight
=
comp
.
getPreferredSize
().
height
;
}
if
(
rowHeight
>
0
)
{
resultsTable
.
setRowHeight
(
row
,
rowHeight
+
CELL_BOTTOM_MARGIN
);
}
}
}
}
}
/**
* Update the column widths so that the Value column has most of the space.
*/
private
void
updateColumnSizes
()
{
private
void
updateColumnSizes
()
{
resultsTable
.
setAutoResizeMode
(
javax
.
swing
.
JTable
.
AUTO_RESIZE_NEXT_COLUMN
);
Enumeration
<
TableColumn
>
columns
=
resultsTable
.
getColumnModel
().
getColumns
();
Enumeration
<
TableColumn
>
columns
=
resultsTable
.
getColumnModel
().
getColumns
();
while
(
columns
.
hasMoreElements
())
{
while
(
columns
.
hasMoreElements
())
{
TableColumn
col
=
columns
.
nextElement
();
TableColumn
col
=
columns
.
nextElement
();
...
@@ -551,6 +619,7 @@ private void updateView(ViewUpdate viewUpdate) {
...
@@ -551,6 +619,7 @@ private void updateView(ViewUpdate viewUpdate) {
DefaultTableModel
tModel
=
((
DefaultTableModel
)
resultsTable
.
getModel
());
DefaultTableModel
tModel
=
((
DefaultTableModel
)
resultsTable
.
getModel
());
tModel
.
setDataVector
(
viewUpdate
.
tableContents
.
getRows
(),
COLUMN_HEADERS
);
tModel
.
setDataVector
(
viewUpdate
.
tableContents
.
getRows
(),
COLUMN_HEADERS
);
updateColumnSizes
();
updateColumnSizes
();
updateRowHeights
();
resultsTable
.
clearSelection
();
resultsTable
.
clearSelection
();
this
.
setCursor
(
null
);
this
.
setCursor
(
null
);
...
@@ -568,6 +637,7 @@ private synchronized void startNewTask(SwingWorker<ViewUpdate, Void> task) {
...
@@ -568,6 +637,7 @@ private synchronized void startNewTask(SwingWorker<ViewUpdate, Void> task) {
DefaultTableModel
tModel
=
((
DefaultTableModel
)
resultsTable
.
getModel
());
DefaultTableModel
tModel
=
((
DefaultTableModel
)
resultsTable
.
getModel
());
tModel
.
setDataVector
(
waitRow
,
COLUMN_HEADERS
);
tModel
.
setDataVector
(
waitRow
,
COLUMN_HEADERS
);
updateColumnSizes
();
updateColumnSizes
();
updateRowHeights
();
resultsTable
.
clearSelection
();
resultsTable
.
clearSelection
();
// The output of the previous task is no longer relevant.
// The output of the previous task is no longer relevant.
if
(
currentTask
!=
null
)
{
if
(
currentTask
!=
null
)
{
...
@@ -758,4 +828,27 @@ protected void done() {
...
@@ -758,4 +828,27 @@ protected void done() {
}
}
}
}
}
}
/**
* TableCellRenderer for displaying multiline text.
*/
private
class
MultiLineTableCellRenderer
implements
javax
.
swing
.
table
.
TableCellRenderer
{
@Override
public
Component
getTableCellRendererComponent
(
javax
.
swing
.
JTable
table
,
Object
value
,
boolean
isSelected
,
boolean
hasFocus
,
int
row
,
int
column
)
{
javax
.
swing
.
JTextArea
jtex
=
new
javax
.
swing
.
JTextArea
();
if
(
value
instanceof
String
)
{
jtex
.
setText
((
String
)
value
);
jtex
.
setLineWrap
(
true
);
jtex
.
setWrapStyleWord
(
true
);
}
//cell backgroud color when selected
if
(
isSelected
)
{
jtex
.
setBackground
(
javax
.
swing
.
UIManager
.
getColor
(
"Table.selectionBackground"
));
}
else
{
jtex
.
setBackground
(
javax
.
swing
.
UIManager
.
getColor
(
"Table.background"
));
}
return
jtex
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment