mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
addressing codacy remarks
This commit is contained in:
parent
78d69f173b
commit
664deb65bc
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.datasourcesummary.datamodel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -41,6 +40,9 @@ public class DataSourceTopDomainsSummary {
|
||||
// this.provider = provider;
|
||||
// }
|
||||
|
||||
/*
|
||||
* a function to calculate a result from 2 paramaters
|
||||
*/
|
||||
interface Function2<A1,A2,O> {
|
||||
O apply(A1 a1, A2 a2);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
* uses Case.getCurrentCaseThrows().getSleuthkkitCase().
|
||||
*/
|
||||
public interface SleuthkitCaseProvider {
|
||||
public static final SleuthkitCaseProvider DEFAULT = () -> Case.getCurrentCaseThrows().getSleuthkitCase();
|
||||
SleuthkitCaseProvider DEFAULT = () -> Case.getCurrentCaseThrows().getSleuthkitCase();
|
||||
|
||||
SleuthkitCase get() throws NoCurrentCaseException;
|
||||
}
|
||||
|
@ -106,17 +106,7 @@ public class DataFetchWorker<A, R> extends SwingWorker<R, Void> {
|
||||
|
||||
@Override
|
||||
protected R doInBackground() throws Exception {
|
||||
if (Thread.interrupted() || isCancelled()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
R result = processor.process(args);
|
||||
|
||||
if (Thread.interrupted() || isCancelled()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
return result;
|
||||
return processor.process(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,14 +125,14 @@ public class DataFetchWorker<A, R> extends SwingWorker<R, Void> {
|
||||
} catch (ExecutionException ex) {
|
||||
Throwable inner = ex.getCause();
|
||||
// if cancelled during operation, simply return
|
||||
if (inner != null && inner instanceof InterruptedException) {
|
||||
if (inner instanceof InterruptedException) {
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, there is an error to log
|
||||
logger.log(Level.WARNING, "There was an error while fetching results.", ex);
|
||||
|
||||
if (inner != null && inner instanceof DataProcessorException) {
|
||||
if (inner instanceof DataProcessorException) {
|
||||
resultHandler.accept(DataLoadingResult.getLoadError((DataProcessorException) inner));
|
||||
}
|
||||
return;
|
||||
|
@ -21,7 +21,7 @@ package org.sleuthkit.autopsy.guiutils.internal;
|
||||
/**
|
||||
* The intermediate or end result of a loading process.
|
||||
*/
|
||||
public class DataLoadingResult<R> {
|
||||
public final class DataLoadingResult<R> {
|
||||
|
||||
// The state of loading in the result.
|
||||
public enum ProcessorState {
|
||||
|
@ -26,35 +26,6 @@ package org.sleuthkit.autopsy.guiutils.internal;
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DataProcessor<I, O> {
|
||||
|
||||
/**
|
||||
* Wraps a DataProcessor in statements looking to see if the thread has been
|
||||
* interrupted and throws an InterruptedException in that event.
|
||||
*
|
||||
* @param toBeWrapped The data processor to be wrapped.
|
||||
*
|
||||
* @return The wrapped data processor that will throw an interrupted
|
||||
* exception before or after the toBeWrapped data processor has been
|
||||
* run.
|
||||
*/
|
||||
public static <I1, O1> DataProcessor<I1, O1> wrap(DataProcessor<I1, O1> toBeWrapped) {
|
||||
return new DataProcessor<I1, O1>() {
|
||||
@Override
|
||||
public O1 process(I1 input) throws InterruptedException, DataProcessorException {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
O1 output = toBeWrapped.process(input);
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that accepts an input argument and outputs a result. Since it
|
||||
* is meant to be used with the DataFetchWorker, it throws an interrupted
|
||||
|
@ -23,6 +23,7 @@ package org.sleuthkit.autopsy.guiutils.internal;
|
||||
* DataProcessor.
|
||||
*/
|
||||
public class DataProcessorException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
|
@ -42,6 +42,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
"DataResultJTable_errorMessage_defaultText=There was an error loading results."
|
||||
})
|
||||
public class DataResultJTable<T> extends JPanel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* JTables don't allow display messages. So this LayerUI is used to display
|
||||
@ -50,6 +51,7 @@ public class DataResultJTable<T> extends JPanel {
|
||||
* https://docs.oracle.com/javase/tutorial/uiswing/misc/jlayer.html.
|
||||
*/
|
||||
private static class Overlay extends LayerUI<JComponent> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final JLabel child;
|
||||
private boolean visible;
|
||||
@ -96,9 +98,6 @@ public class DataResultJTable<T> extends JPanel {
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
int w = c.getWidth();
|
||||
int h = c.getHeight();
|
||||
|
||||
// Paint the underlying view.
|
||||
super.paint(g, c);
|
||||
|
||||
@ -106,6 +105,9 @@ public class DataResultJTable<T> extends JPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
int w = c.getWidth();
|
||||
int h = c.getHeight();
|
||||
|
||||
// paint the jlabel if visible.
|
||||
child.setBounds(0, 0, w, h);
|
||||
child.paint(g);
|
||||
@ -119,17 +121,16 @@ public class DataResultJTable<T> extends JPanel {
|
||||
private static final String DEFAULT_NO_RESULTS_MESSAGE = "";
|
||||
private static final String DEFAULT_NOT_LOADED_MESSAGE = "";
|
||||
|
||||
private final JTable table;
|
||||
private final JScrollPane tableScrollPane;
|
||||
private final JLayer<JComponent> dualLayer;
|
||||
private final Overlay overlayLayer;
|
||||
private final PojoListTableDataModel<T> tableModel;
|
||||
|
||||
private String loadingMessage = DEFAULT_LOADING_MESSAGE;
|
||||
private String errorMessage = DEFAULT_ERROR_MESSAGE;
|
||||
private String noResultsMessage = DEFAULT_NO_RESULTS_MESSAGE;
|
||||
private String notLoadedMessage = DEFAULT_NOT_LOADED_MESSAGE;
|
||||
|
||||
private PojoListTableDataModel<T> tableModel = null;
|
||||
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
@ -137,12 +138,12 @@ public class DataResultJTable<T> extends JPanel {
|
||||
*/
|
||||
public DataResultJTable(PojoListTableDataModel<T> tableModel) {
|
||||
this.tableModel = tableModel;
|
||||
this.table = new JTable(tableModel, tableModel.getTableColumnModel());
|
||||
this.table.getTableHeader().setReorderingAllowed(false);
|
||||
JTable table = new JTable(tableModel, tableModel.getTableColumnModel());
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
|
||||
this.overlayLayer = new Overlay();
|
||||
this.tableScrollPane = new JScrollPane(table);
|
||||
this.dualLayer = new JLayer<JComponent>(tableScrollPane, overlayLayer);
|
||||
JLayer<JComponent> dualLayer = new JLayer<JComponent>(tableScrollPane, overlayLayer);
|
||||
setLayout(new BorderLayout());
|
||||
add(dualLayer, BorderLayout.CENTER);
|
||||
}
|
||||
@ -157,21 +158,21 @@ public class DataResultJTable<T> extends JPanel {
|
||||
/**
|
||||
* @return The message shown when there is an exception.
|
||||
*/
|
||||
String getErrorMessage() {
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The message shown when there are no results.
|
||||
*/
|
||||
String getNoResultsMessage() {
|
||||
public String getNoResultsMessage() {
|
||||
return noResultsMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The message shown when the table has not been loaded.
|
||||
*/
|
||||
String getNotLoadedMessage() {
|
||||
public String getNotLoadedMessage() {
|
||||
return notLoadedMessage;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
* class provides a TableModel and TableColumnModel to be used with that class.
|
||||
*/
|
||||
public class DefaultPojoListTableDataModel<T> extends AbstractTableModel implements PojoListTableDataModel<T> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Describes the horizontal alignment.
|
||||
@ -64,7 +65,6 @@ public class DefaultPojoListTableDataModel<T> extends AbstractTableModel impleme
|
||||
* The default cell model.
|
||||
*/
|
||||
public static class DefaultCellModel implements CellModel {
|
||||
|
||||
private final String text;
|
||||
private String tooltip;
|
||||
|
||||
@ -300,6 +300,9 @@ public class DefaultPojoListTableDataModel<T> extends AbstractTableModel impleme
|
||||
case RIGHT:
|
||||
defaultCell.setHorizontalAlignment(JLabel.RIGHT);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown horizontal alignment choice: " +
|
||||
columnModel.getCellHorizontalAlignment());
|
||||
}
|
||||
} else {
|
||||
defaultCell.setHorizontalAlignment(JLabel.LEFT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user